Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang error when compiling on OS X (Mavericks) #13

Closed
Baekalfen opened this issue Oct 7, 2013 · 12 comments
Closed

Clang error when compiling on OS X (Mavericks) #13

Baekalfen opened this issue Oct 7, 2013 · 12 comments
Labels

Comments

@Baekalfen
Copy link

I followed the guide from README.md for installing on Mac OS X. Netbeans, Xcode, Qt 4 and SDL installed correctly and i added qmake to PATH.
But when i try to compile it using:
make -f nbproject/Makefile-Release.mk SUBPROJECTS= .build-conf

I get the following error:
ld: library not found for -lSDLmain
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [dist/Release/CLang-MacOSX/Gearboy] Error 1
make: *** [.build-conf] Error 2

screen shot 2013-10-07 at 15 17 09
(Sorry I can't make a code-block, I'm new at GitHub)

@drhelius
Copy link
Owner

drhelius commented Oct 7, 2013

Hi and thank you for your feedback.

It seems your environment isn't properly configured and can't find libSDLmain.a

By the way, if you installed Netbeans you can just open and run the project with the IDE instead of running make, but that won't fix your problem though.

Check this link for the installation and configuration of SDL: http://stackoverflow.com/questions/4591076/c-sdl-on-macosx-without-xcode

This may solve your problem.

@Baekalfen
Copy link
Author

Thanks for the quick answer!
Although I'm quite new to all this, so when the instruction says "./configure --prefix=/home/user/SDL" should I replace "/home/user/" with my home dir? Because just copy-pasting gives me some errors:

/bin/sh build-scripts/mkinstalldirs /home/user/SDL/bin
mkdir -p -- /home/user/SDL/bin
mkdir: /home/user/SDL/bin: Operation not supported
make: *** [install-bin] Error 1

I tried replacing the directory to my home dir and it installed succesfully. Now what do i do? I still get the same error when trying to compile GearBoy. Should I somehow add the SDL directory to the make process?

@drhelius
Copy link
Owner

drhelius commented Oct 7, 2013

Yes that guide assumes you have the SDL extracted on your home dir.

Try this: go to library/frameworks/ and rename SDLmain to SDL

Found here: http://uzebox.org/forums/viewtopic.php?f=9&t=532

@Baekalfen
Copy link
Author

The directory "~/Library/Frameworks/" doesn't exist, so i tried "/Library/Framework/" instead. The only SDL file is already called "SDL.framework" so i tried to rename it to "SDLmain.framework", but that didn't change anything...

This might be what goes wrong: http://forums.macrumors.com/showthread.php?t=1495793
But changing the line:
LDLIBSOPTIONS=-lSDLmain -lSDL -Wl,-framework,Cocoa
to
LDLIBSOPTIONS=-lSDL -Wl,-framework,SDL,Cocoa
or
LDLIBSOPTIONS=-Wl,-framework,SDL,Cocoa
or
LDLIBSOPTIONS=-Wl,-framework SDL -framework Cocoa
doesn't help either..

If it is any help, the libSDLmain.a is located at "/usr/local/lib/" and "/opt/local/lib/" and if I write "sdl-config --libs" in the terminal (from "~/"), it returns: "-L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa"

I'm not sure if i installed SDL wrong... Can you give a little more detail on what you mean by: "Install and configure SDL for development."?

@drhelius
Copy link
Owner

drhelius commented Oct 8, 2013

I'm sorry but I can't remember the steps I took to install SDL on my Mac.
I remember having similar problems when I first installed it last year. I also remember following the readmes inside the sdk to complete the installation. I probably made some tweak in my environment after that but I can't remember what.
It could be also related to the Qt framework, both libraries try to redefine the 'main' function and Gearboy uses the main function from Qt.

@Baekalfen
Copy link
Author

I have tried doing everything from the readme again... I still can't get it to work.
If someone can confirm that the steps work, I would really like to know what I have done wrong.

I will of cause make a post if I solve it myself.

@drhelius
Copy link
Owner

If you feel that I have to change something in the makefile or with the Netbeans project just tell me, or send me a pull request.

I'll make my best to integrate you're findings so any other doesn't have to fix this again. If I have a chance I'll try with a clean environment too.

Thanks

@drhelius
Copy link
Owner

drhelius commented Dec 7, 2013

I started today with a new Mac installation.

I found that SDL 1.2 no longer compiles on Mavericks so I'm updating both Gearboy and Gearsystem to use SDL 2.

SDL 2 compiled without any issues on my Mac and I was able to build Gearboy with the latest version of Netbeans so I'm closing this issue.

Let me know if you have any further issues.

@drhelius drhelius closed this as completed Dec 7, 2013
@Baekalfen
Copy link
Author

I tried now on a completely new MacBook. NetBeans 7.4, Xcode 5, Qt 4.8.5 and SDL 2.0.1 installed successfully (I think). I still get the same error:

ld: library not found for -lSDL2main
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [dist/Release/CLang-MacOSX/Gearboy] Error 1
make: *** [.build-conf] Error 2

Can you describe exactly how you installed SDL? I just moved the SDL2.framework to /Library/Frameworks

@drhelius
Copy link
Owner

Just followed the readme file for Mac and
./configure
make
sudo make install

@drhelius drhelius reopened this Feb 22, 2014
@Baekalfen
Copy link
Author

Now it works! Fantastic! :)

I downloaded the SDL 2 ->source code<- and compiled it as you described. Maybe that should be more clear in the README-file if that is what you meant to do in the first place?

@drhelius
Copy link
Owner

Yes that's it, now you told me about the framework file I did realize about your error.
With Netbeans you need the environment as if you were compiling from the command line, I'll make that clear in the README.
Anyway, making a project for Xcode should be the proper way of fixing this, so anyone using a Mac can just open the project and compile just like the iOS port.
Thank you and have fun.

@drhelius drhelius added the bug label Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants