Jump to content
  • Advertisement
Sign in to follow this  
serratemplar

dynamic vs static link error, Mac OS X

This topic is 4064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm new to Mac OS X; picked up a nice new MacBook to do cross platform development on (working with SDL, GTK, etc). For my new, recent project I've run into a link error I've not seen before: /usr/bin/ld: main.o is input for the dynamic link editor, is not relocatable by the static link editor again Googling has given me little understanding of this issue: from what I can tell, by building main.cpp into main.o, g++ in darwin is making it a dynamically linkable library? So it's not allowing me to link it in the way I am accustomed. Here is my (very simple) makefile:

.SUFFIXES = .cpp .o

GTK_INIT = `pkg-config --cflags --libs gtk+-2.0`
BOOST_LIB = -lboost_filesystem -I/opt/local/include -L/opt/local/lib

OBJECT_FILES = main.o

all:		pictview

pictview:	$(OBJECT_FILES)
	g++ $(OBJECT_FILES) -o pictview $(GTK_INIT) $(BOOST_LIB)
	


main.o:		main.cpp
	g++ main.cpp -o main.o $(GTK_INIT) $(BOOST_LIB)
	
clean:
	rm pictview
	rm main.o

Please note that I am able to compile/build if I put it all on one line...but this project (and many others I work on) will end up being quite large, spanning multiple files...so it's necessary to build each object file individually so that modifying only one doesn't require I rebuild the entire project. I'm sure many of you are familiar with this in general. Does anyone have experience with this Mac-side? Any and all help is appreciated =) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Like on Linux, g++ main.cpp -o main.o compiles and links a binary.

You need the -c switch to g++ to only compile it. You're trying to link it twice.

Share this post


Link to post
Share on other sites
No problem, I hope you're enjoying your new computer. Make sure to pick up QuickSilver and TextMate.

Share this post


Link to post
Share on other sites
This thing is great =) I've been using the text-editor portion of XCode, which is a bit rough. I'll definately look into both of those apps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!