Results 1 to 11 of 11

Thread: C, Eclipse and multiple object files

  1. #1
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts

    C, Eclipse and multiple object files

    Hi guys,

    I have an Eclipse C project that currently spits out an executable binary.

    I want to have part of the project compiled into a shared object file and then have the rest compiled into an executable.

    Seems I can only have one or the other; what am I missing?

    Cheers,
    Steve.
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  2. #2
    Get in the van. Fraz's Avatar
    Join Date
    Aug 2007
    Location
    Bristol
    Posts
    2,919
    Thanks
    284
    Thanked
    397 times in 231 posts
    • Fraz's system
      • Motherboard:
      • Gigabyte X58A-UD5
      • CPU:
      • Watercooled i7-980X @ 4.2 GHz
      • Memory:
      • 24GB Crucial DDR3-1333
      • Storage:
      • 240 GB Vertex2E + 2 TB of Disk
      • Graphics card(s):
      • Water-cooled Sapphire 7970 @ 1175/1625
      • PSU:
      • Enermax Modu87+
      • Case:
      • Corsair 700D
      • Operating System:
      • Linux Mint 12 / Windows 7
      • Monitor(s):
      • Dell 30" 3008WFP and two Dell 24" 2412M
      • Internet:
      • Virgin Media 60 Mbps

    Re: C, Eclipse and multiple object files

    Quote Originally Posted by Steve View Post
    Seems I can only have one or the other; what am I missing?
    I presume you are doing this with a managed make file right?

    I'm not sure of the solution exactly, but have you tried splitting the code into two projects, one project compiled to a .so/.dll the other compiled as an executable.

    Alternatively, you could write your own make file.

  3. #3
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts

    Re: C, Eclipse and multiple object files

    My fallback is to split into two projects, but I'd rather not - guess it doesn't really make much difference if I do, though.

    And yes, I'm letting eclipse manage the makefile, perhaps I should get a bit more involved.

    edit: Looks like I might be able to do it with multiple make targets. I'll have a go at that after lunch.
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  4. #4
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: C, Eclipse and multiple object files

    You'll need to manually edit your make files. It's fairly straight forward unless your project begins to get seriously unwieldy.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  5. #5
    Get in the van. Fraz's Avatar
    Join Date
    Aug 2007
    Location
    Bristol
    Posts
    2,919
    Thanks
    284
    Thanked
    397 times in 231 posts
    • Fraz's system
      • Motherboard:
      • Gigabyte X58A-UD5
      • CPU:
      • Watercooled i7-980X @ 4.2 GHz
      • Memory:
      • 24GB Crucial DDR3-1333
      • Storage:
      • 240 GB Vertex2E + 2 TB of Disk
      • Graphics card(s):
      • Water-cooled Sapphire 7970 @ 1175/1625
      • PSU:
      • Enermax Modu87+
      • Case:
      • Corsair 700D
      • Operating System:
      • Linux Mint 12 / Windows 7
      • Monitor(s):
      • Dell 30" 3008WFP and two Dell 24" 2412M
      • Internet:
      • Virgin Media 60 Mbps

    Re: C, Eclipse and multiple object files

    Quote Originally Posted by Steve View Post
    And yes, I'm letting eclipse manage the makefile, perhaps I should get a bit more involved.
    Best avoided if you can. I hate Makefiles with a passion.

    They're fine once you've got them working, but the problem for me is that you only need to write them once in a blue moon, and when it comes round to fixing one or writing a new one, you've completely forgot how they work again, and it just looks like someone has vomited a load of random symbols into a text file...

  6. #6
    Get in the van. Fraz's Avatar
    Join Date
    Aug 2007
    Location
    Bristol
    Posts
    2,919
    Thanks
    284
    Thanked
    397 times in 231 posts
    • Fraz's system
      • Motherboard:
      • Gigabyte X58A-UD5
      • CPU:
      • Watercooled i7-980X @ 4.2 GHz
      • Memory:
      • 24GB Crucial DDR3-1333
      • Storage:
      • 240 GB Vertex2E + 2 TB of Disk
      • Graphics card(s):
      • Water-cooled Sapphire 7970 @ 1175/1625
      • PSU:
      • Enermax Modu87+
      • Case:
      • Corsair 700D
      • Operating System:
      • Linux Mint 12 / Windows 7
      • Monitor(s):
      • Dell 30" 3008WFP and two Dell 24" 2412M
      • Internet:
      • Virgin Media 60 Mbps

    Re: C, Eclipse and multiple object files

    For instance, an excerpt from one of my projects:

    Code:
    # Generate the wrapper code with swig
    $(SwigDir)/common/$(PyModuleName)_wrap.cc : $(SwigHeaderDir)/$(PyModuleName).i 
    	$(SWIG) -shadow -c++ -python -o $@ $<
    
    # Generate the single wrapper interface file for the module by creating a file that %includes the individual .i files
    $(SwigHeaderDir)/$(PyModuleName).i : $(SourcesToWrap:%.i=$(SwigHeaderDir)/%.i)
    	$(SwigHeaderDir)/makePackageInterface.sh $(PyModuleName).i $(SourcesToWrap)	
    	mv $(PyModuleName).i $@
    
    # Dummy rule - nothing automatically generates the .i files
    $(SourcesToWrap:%.i=$(SwigHeaderDir)/%.i) :
    
    # Compile the wrapper to an object file
    $(SwigLibDir)/$(PyModuleName)_wrap.o : $(SwigDir)/common/$(PyModuleName)_wrap.cc
    	$(CXX) -c -fPIC -o $@ $^ -I$(PythonIncDir) $(IncludeDirs:%=-I%)
    Syntax is clear as a bell, isn't it...

  7. #7
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: C, Eclipse and multiple object files

    Makefiles are easy. You should try GNU autotools for size, now there's a way to spoil/soil your brain.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  8. #8
    Get in the van. Fraz's Avatar
    Join Date
    Aug 2007
    Location
    Bristol
    Posts
    2,919
    Thanks
    284
    Thanked
    397 times in 231 posts
    • Fraz's system
      • Motherboard:
      • Gigabyte X58A-UD5
      • CPU:
      • Watercooled i7-980X @ 4.2 GHz
      • Memory:
      • 24GB Crucial DDR3-1333
      • Storage:
      • 240 GB Vertex2E + 2 TB of Disk
      • Graphics card(s):
      • Water-cooled Sapphire 7970 @ 1175/1625
      • PSU:
      • Enermax Modu87+
      • Case:
      • Corsair 700D
      • Operating System:
      • Linux Mint 12 / Windows 7
      • Monitor(s):
      • Dell 30" 3008WFP and two Dell 24" 2412M
      • Internet:
      • Virgin Media 60 Mbps

    Re: C, Eclipse and multiple object files

    Quote Originally Posted by aidanjt View Post
    Makefiles are easy.
    I disagree, but it depends how often you have to write them, like I say. Last time I wrote a Makefile was about 2 years ago, and now when I look at one it makes me wince. The only language I can think of that is more ugly is Perl.

  9. #9
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: C, Eclipse and multiple object files

    M4 is easily considerably more hideous than both.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  10. #10
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts

    Re: C, Eclipse and multiple object files

    In the end I split it into two projects.

    So now I have a nice shared object and a program that uses it

    And all without mangling any makefiles.
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  11. #11
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts

    Re: C, Eclipse and multiple object files

    Quote Originally Posted by Fraz View Post
    The only language I can think of that is more ugly is Perl.
    Yeah, but imagine if Larry Wall had invented Makefiles...
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Anyone got the new Saitek Eclipse II Keyboard?
    By abeacock in forum PC Hardware and Components
    Replies: 19
    Last Post: 31-10-2006, 01:36 AM
  2. Using Java 1.5 Generics In Eclipse IDE
    By LWA in forum Software
    Replies: 3
    Last Post: 09-02-2005, 12:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •