Closed xasmx closed 11 years ago
I'll see what I can do about getting hold of a Mac to try and reproduce this on.
I actually got past this by building sdl from source instead of installing it from macports or homebrew, so it's just an inconvenience. Anyway, even after that I'm not able to get the build working. Now I'm getting the following:
cp /usr/local/lib/libSDLmain.a libSDLXmain.a
ar -x libSDLXmain.a SDLMain.o || rm -f -f libSDLXmain.a
ld -r SDLMain.o -o SDLXMain.o -alias _main _SDLX_main -unexported_symbol main || rm -f -f libSDLXmain.a
mv SDLXMain.o SDLMain.o || rm -f -f libSDLXmain.a
chmod u+w libSDLXmain.a || rm -f -f libSDLXmain.a
ar -r libSDLXmain.a SDLMain.o || rm -f -f libSDLXmain.a
rustc sdl.rc -o libsdl.dummy
error: linking with cc
failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -m64 -o libsdl-34b7eedb9132850-0.2.dylib libsdl.o -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lcore-c3ca5d77d81b46c1-0.6 -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lstd-4782a756585a81-0.6 -L. -lSDLXmain -framework AppKit -framework Foundation -lSDL -dynamiclib -Wl,-install_name,@rpath/libsdl-34b7eedb9132850-0.2.dylib -lrustrt -Wl,-no_compact_unwind -lmorestack -Wl,-rpath,@executable_path/../../../../../usr/local/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-apple-darwin/lib
note: Undefined symbols for architecture x86_64:
"_SDL_main", referenced from:
-[SDLMain applicationDidFinishLaunching:] in libSDLXmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error make: *\ [libsdl.dummy] Error 101
Same here
I was getting this error, dug in and figured out what the makefile was doing and kept poking until it compiled. Result was a rust macro error.
If you're on the current homebrew rust (0.5), you need to git co b8b0ce9061ae9e17907b9380a4bc60bf877df2e4
in the rust-sdl directory before doing the make dance. Compiled without issue for me.
doing git co b8b0ce9061ae9e17907b9380a4bc60bf877df2e4
in rust-sdl produces the same error
note: Undefined symbols for architecture x86_64: "_SDL_main", referenced from: -[SDLMain applicationDidFinishLaunching:] in libSDLXmain.a(SDLMain.o)
for me (ie, that didn't fix it for me). Rust 0.5, current master branch of rust-sdl, SDL 1.2.15 from homebrew.
I have managed to get it working by adding -alias _SDLX_main _SDL_main
to line 37 of the Makefile after the _SDLX_main alias. I'm not sure if that is a sane thing to do however. The output is a libsdl-
The make check command seems to be failing now, though that looks like it is a macro error:
test.rs:97:46: 97:66 error: cannot apply unary operator
!
to type~str
test.rs:97 event::QuitEvent => fail!(~"Explicit quit"), ^~~~~~~~ test.rs:103:20: 103:51 error: cannot apply unary operator!
to type~str
test.rs:103 fail!(~"Failed to set video mode"); ^~~~~~~test.rs:180:40: 181:9 error: cannot apply unary operator!
to type~str
test.rs:180 result::Err(message) => fail!(message) test.rs:181 }; error: aborting due to 3 previous errors
Rust-SDL is currently built against Incoming, rather than Master, and that might be causing your problems. Try checking out Rust's Incoming branch and building against that.
For me, I can compile if I check out f2df562e6eaf56a98a5807a2ff5d193e6b4396c6. The next commit from that (4c3d2c7f7a01c97f28ac1564ea39967ed7efc7cc) is that one that breaks the build.
I'm running with incoming and after adding "-alias _SDLX_main _SDL_main" as DylanSale suggested, I'm able to now compile the head revision. Though, not sure if that alias is the right thing to do.
@xasmx Is your SDL working after adding the -alias
line? Try a simple app that uses set_video_mode
, or you could try rust-airhockey or sprocketnes.
The whole reason for these weird shenanigans regarding SDLX_main
is that we need SDL's main
in order to set up the window properly on the Mac, but Rust also wants to create the main
function, so we have to do some renaming in order to make it work. On Linux, SDL's main
is not needed, but on Mac it is.
Following up on this. Looks like my git revision rollback worked because I didn't re-generate the Makefile. I wound up:
mozilla/rust
master checkout, ./configure && make && make install
brew install sdl
./configure && make
builds cleanly.I believe I hit all the other errors mentioned in this thread starting with the homebrew rust 0.5 and trying to work around it. I just repeated everything except the rust master build (takes too long) and got the same result so I think that works. Adding an -alias _SDLX_main _SDL_main
results in a duplicate symbol error.
@pcwalton Updating the homebrew build to allow for HEAD and devel (docs search devel
) targets would simplify things for us interested rust spectators. If the checkpoint builds would work if installed to the proper system locations, that might be a reasonable option for devel. I'd be willing to try to do it but I'll probably need some handholding since I don't know things like whether master or incoming is the correct branch for HEAD.
I can confirm compiling with the rust incoming branch works. The alias -alias _SDLX_main _SDL_main
line has the duplicate error @grayrest mentions, so don't do that.
Is anyone still having this issue when building against Incoming with the latest version of Rust-SDL?
I'll see if I can figure out how to get this tested today, no promises. I upgraded to latest incoming, which broke rust for me completely, so I'll have to get rust itself fixed before I can test this.
It's now compiling for me out of the box and was also able to compile and run 'demo' from the demo folder. Thanks a lot, everyone! :)
Excellent! I assume @pcwalton's changes to the way the OSX builder thing in the make file fixed it, the clever chap he is. Anybody else still having this issue?
I'm going to assume this is fixed and closing it. If anyone else is still having problems, feel free to comment and I'll reopen it.
Trying to build on OSX-10.8.2. libSDL installed using macports.
./configure && make make: *\ No rule to make target
/usr/local/lib/libSDLmain.a', needed by
libSDLXmain.a'. Stop.Edited Makefile SDL_PREFIX to match where macports installed it: SDL_PREFIX ?= /usr/local/lib -> SDL_PREFIX ?= /opt/local/lib
make rustc sdl.rc -o libsdl.dummy error: linking with
cc
failed with code 1 note: cc arguments: -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -m64 -o libsdl-34b7eedb9132850-0.2.dylib libsdl.o -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lcore-c3ca5d77d81b46c1-0.6 -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lstd-4782a756585a81-0.6 -L. -lSDLXmain -framework AppKit -framework Foundation -lSDL -dynamiclib -Wl,-install_name,@rpath/libsdl-34b7eedb9132850-0.2.dylib -lrustrt -Wl,-no_compact_unwind -lmorestack -Wl,-rpath,@executable_path/../../../../../usr/local/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-apple-darwin/lib note: ld: library not found for -lSDL clang: error: linker command failed with exit code 1 (use -v to see invocation)error: aborting due to previous error make: *\ [libsdl.dummy] Error 101