I am trying to compile a sfml project via command line under mac osx. Currently, I'm not able to get it to compile. Any help guys?
For the simple window application they include as part of the templates. I was able to compile it with the following command.
g++ -framework OpenGL -framework SFML -framework SFML-window main.cpp
I hope that helps
You can compile with only one instruction:
g++ -framework sfml-window -framework sfml-graphics -framework sfml-system main.cpp -o main
Related
I am trying to add freeglut to my program but I didn't find any way to do that. In MacOs to add glut library and glu i had to compile from terminal with :
g++-9 -framework GLUT -framework OpenGL
My purpose was to add freeglut in order to use glutLeaveMainLoop() in my program.
So I added the Library but i get this error:
Undefined symbols for architecture x86_64:
"_glutLeaveMainLoop"
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I had the same errors when I tried compiling my program without adding -framework OpenGL -framework GLUT
Is it possible to compile with g++ using also freeglut ?
Since MacOs doesn't have a freeglut library itself, after downloading the library with brew, I solved the problem myself by adding the -L and the -l :
g++-9 -framework GLUT -framework OpenGL -L /usr/local/Cellar/freeglut/3.0.0/lib -lglut file.cpp
I am using XCode 7.1 on Mac OS X 10.11.1.
I am using an addon called ofXopenNI with openFrameworks, which is basically an OpenNI interface for openFrameworks. It has some requirements which I installed and linked to my XCode project. Still, there's one linking error that I am unable to fix. Here it is (I pasted an image so that I don't miss out on anything):
The problem is that libXnFormats is already included in my project, and yet this issue comes up. This is how I think it's included in the project:
(The second one)
I know there are a lot of Mach-O linking error questions on SO, but this seemed specific. Anyone knows a fix to this?
Here's the error message in text format (since it was asked for):
Ld bin/huReconDebug.app/Contents/MacOS/huReconDebug normal x86_64
cd /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin -F/Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin -F/Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/../../../libs/glut/lib/osx -filelist /Users/ranveer/Library/Developer/Xcode/DerivedData/huRecon-eiqxyontximqaegxzkvzzaxrfiqs/Build/Intermediates/huRecon.build/Debug/huRecon.build/Objects-normal/x86_64/huReconDebug.LinkFileList -mmacosx-version-min=10.11 -dead_strip ../../../libs/poco/lib/osx/PocoCrypto.a ../../../libs/poco/lib/osx/PocoData.a ../../../libs/poco/lib/osx/PocoDataODBC.a ../../../libs/poco/lib/osx/PocoDataSQLite.a ../../../libs/poco/lib/osx/PocoFoundation.a ../../../libs/poco/lib/osx/PocoNet.a ../../../libs/poco/lib/osx/PocoNetSSL.a ../../../libs/poco/lib/osx/PocoUtil.a ../../../libs/poco/lib/osx/PocoXML.a ../../../libs/poco/lib/osx/PocoZip.a ../../../libs/tess2/lib/osx/tess2.a ../../../libs/glew/lib/osx/glew.a ../../../libs/cairo/lib/osx/cairo-script-interpreter.a ../../../libs/cairo/lib/osx/cairo.a ../../../libs/cairo/lib/osx/pixman-1.a ../../../libs/fmodex/lib/osx/libfmodex.dylib ../../../libs/rtAudio/lib/osx/rtAudio.a ../../../libs/openssl/lib/osx/crypto.a ../../../libs/openssl/lib/osx/ssl.a ../../../libs/glfw/lib/osx/libglfw3.a ../../../libs/FreeImage/lib/osx/freeimage.a ../../../libs/freetype/lib/osx/freetype.a ../../../addons/ofxAssimpModelLoader/libs/assimp/lib/osx/assimp.a ../../../addons/ofxKinect/libs/libusb-1.0/lib/osx/usb-1.0.a ../../../addons/ofxOpenCv/libs/opencv/lib/osx/opencv.a -stdlib=libstdc++ -framework Accelerate /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin/data/lXnFormats.dylib -lXnFormats -framework QTKit -lXnDDK -framework GLUT -lusb-1.0.0 /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin/data/XnFormats.dylib /Users/ranveer/BTP/openFrameworks/libs/openFrameworksCompiled/lib/osx/openFrameworksDebug.a -framework AGL -lXnVNite_1_5_2 -lnimRecorder -framework ApplicationServices -lXnVCNITE_1_5_2 -framework AudioToolbox -framework CoreAudio -framework CoreFoundation -lnimCodecs -lXnVFeatures_1_5_2 -framework CoreServices -lXnCore -framework OpenGL -lOpenNI -framework QuickTime -lnimMockNodes -lXnDeviceSensorV2KM -framework AppKit -lXnDeviceFile -framework Cocoa -lXnVHandGenerator_1_5_2 -framework IOKit -framework CoreVideo -Xlinker -dependency_info -Xlinker /Users/ranveer/Library/Developer/Xcode/DerivedData/huRecon-eiqxyontximqaegxzkvzzaxrfiqs/Build/Intermediates/huRecon.build/Debug/huRecon.build/Objects-normal/x86_64/huReconDebug_dependency_info.dat -o /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin/huReconDebug.app/Contents/MacOS/huReconDebug
And then,
ld: library not found for -lXnFormats
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I had a similar issue that I got -lXnDDK linker error instead of -lXnFormats. I assume you created new groups by including include and lib folders under ofxOpenNI addon directory. Also, copied the lib folder into bin/data/openni.
I just add bin/data/openni/lib to the Library Search Paths in Build Settings.
I am using Xcode 7.0.1 on MAC OS X 10.10.5.
Rename the library to XnFormats rather than libXnFormats.
I had a strange issue on Xcode recently, when even when using the -l command (which should prefix lib) did want to work for a custom library.
This might be an Xcode bug. However this should get it working for you now.
When I try to run the code I get an Apple O-Mach Linker Error. I'm running up to date XCode 4.6, updated yesterday. I'm running 10.8.2 and here is the error code I get.
A few weeks ago I wasn't getting this issue so I don't know if it's updated SDK from Twilio, the XCode update or what. I've also got one of the library's (libTwilioClient.a) thats red in the frameworks section (This is my first iOS and XCode experience). I've tried linking it and then I get 68 errors about other stuff throughout the program not connecting.
Any help? Oh, BTW, I'm just using the HelloMonkey Example from Twilio's SDK, I haven't changed a single thing except the line pointing to my php server for authentication. Also, I've check for any .m in the headers and there are none. I was hoping that it would be smooth sailing since it's coming from Twilio and it's the "Get Started Quick"... so much for that :/
Ld /Users/Animal/Library/Developer/Xcode/DerivedData/HelloMonkey-
acqupeuamziuogblpxusdjhityyf/Build/Products/Debug-iphonesimulator/HelloMonkey.app
/HelloMonkey normal i386
cd "/Users/Animal/Downloads/TwilioClient-1.1.1-dbefc0b/Quick Start/HelloMonkey
"
setenv IPHONEOS_DEPLOYMENT_TARGET 4.2
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/
iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/
Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk
-L/Users/Animal/Library/Developer/Xcode/DerivedData/HelloMonkey-acqupeuamziuo
gblpxusdjhityyf/Build/Products/Debug-iphonesimulator "-L/Users/Animal/Downloads/
TwilioClient-1.1.1-dbefc0b/Quick Start/HelloMonkey/../.." -F/Users/Animal/
Library/Developer/Xcode/DerivedData/HelloMonkey-acqupeuamziuogblpxusdjhityyf/
Build/Products/Debug-iphonesimulator -filelist /Users/Animal/Library/Developer/
Xcode/DerivedData/HelloMonkey-acqupeuamziuogblpxusdjhityyf/Build/Intermediates/
HelloMonkey.build/Debug-iphonesimulator/HelloMonkey.build/Objects-normal/i386/
HelloMonkey.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -all_load
-fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=4.2
-framework AVFoundation -framework Foundation -framework UIKit -framework
CoreGraphics -framework AudioToolbox -framework CFNetwork -framework
SystemConfiguration -lTwilioClient -o /Users/Animal/Library/Developer/Xcode/
DerivedData/HelloMonkey-acqupeuamziuogblpxusdjhityyf/Build/Products/
Debug-iphonesimulator/HelloMonkey.app/HelloMonkey
ld: library not found for -lTwilioClient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You have to add, other two libraries libcrypto.a and libssl.a along with libTwilioClient.a, then clean and build the project. You are good to go. You can find those libraries in the 'Libraries' folder of the unzipped Twilio bundle. Hope this will help.
I have configure wxWidgets in my MAC OS. In terminal my program in working fine. Here is the following command which I use to run.
gcc -o main main.cpp -I/usr/lib/wx/include/mac-unicode-debug-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXDEBUG__ -D__WXMAC__ -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL -lwx_macud-2.8
How can I configure xcode so that it pass the Header & libs to GCC.
In XCode, bring up the Inspector for the target, look at the "Build" tab, search for "header" and "library". You'll find the relevant configuration options.
I have a mac and I am trying to compile my projects. The standard on the wiki: g++ sdl.cpp -lSDLmain -lSDL -framework Cocoa does not seem to be working it returns that it cannot find -lSDL and -lSDLmain. Any help would be greatly appreciated.
Do you understand the meaning of the flags? The linker is looking for the libraries SDL and SDLmain, are they setup on your machine?
For me the solution is as follows:
g++ -c -I/Library/Frameworks/SDL.framework/Headers -I. -I.. -I/Library/Frameworks/SDL_image.framework/Headers -I/Library/Frameworks/SDL_mixer.framework/Headers -I/Library/Frameworks/SDL_ttf.framework/Headers -I/Library/Frameworks/SDL_net.framework/Headers -I/usr/local/include/SDL -I/usr/local/include/ ./lesson20.cpp -o ./lesson20.o
Now that the object file has been created, we can use this solution:
g++ -L/usr/local/lib -I/Library/Frameworks/SDL.framework/Headers -I. -I.. -I/Library/Frameworks/SDL_image.framework/Headers -lSDLmain -I/Library/Frameworks/SDL_mixer.framework/Headers -I/Library/Frameworks/SDL_ttf.framework/Headers -I/Library/Frameworks/SDL_net.framework/Headers -framework SDL -framework SDL_image -framework Cocoa -framework SDL_mixer -framework SDL_ttf -framework SDL_net -framework OpenGL lesson20.o -o Lesson
This solution assumes that you have the SDL_image, SDL_mixer, SDL_ttf, and SDL_net frameworks installed in the '/Library/Frameworks/' directory.
Since this is difficult to attempt by hand, and the solution is a little messy, it's better to simply write a script to do all of this for you.
The '-I' (capital i) flag tells the compiler where to look for headers. The '-L' flag tells the compiler where to look for libraries. The '-l' (lower case L) flag tells the compiler which libraries to use. The '-framework' flag basically behaves like a '-l' (lower case L) flag.