I am trying to use Eclipse C++ and Irrlicht to a project in school. My problem is to set op the environment.
I have used this http://irrlicht3d.org/wiki/index.php?n=Main.Macintosh
I am using the new MacBook Pro.
I think the error is in this flag.
**** Build of configuration Debug for project HalloWorld2 ****
make all
Building file: ../src/helloworld.cpp
Invoking: GCC C++ Compiler
g++ -I/Users/JAMES/Code/irrlicht-1.7.2/include -O0 -g3 -Wall -c -fmessage-length=0 -arch i386 -fvisibility=hidden -MMD -MP -MF"src/helloworld.d" -MT"src/helloworld.d" -o "src/helloworld.o" "../src/helloworld.cpp"
Finished building: ../src/helloworld.cpp
Building target: HalloWorld2
Invoking: MacOS X C++ Linker
g++ -L/Users/JAMES/Code/irrlicht-1.7.2/source/Irrlicht/MacOSX/build/Release -L/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib -Xlinker -arch i386 -framework OpenGL -framework Carbon -framework Cocoa -framework IOKit -o "HalloWorld2" ./src/helloworld.o -lIrrlicht
i686-apple-darwin11-llvm-g++-4.2: i386: No such file or directory
make: *** [HalloWorld2] Error 1
The problem comes from the use of -Xlinker to pass arguments to the linker. The man page of g++ says:
-Xlinker option
Pass option as an option to the linker. You can use this to supply system-specific linker options which GCC does not know how to recognize.
If you want to pass an option that takes an argument, you must use -Xlinker twice, once for the option and once for the argument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions. It
does not work to write -Xlinker "-assert definitions", because this passes the entire string as a single argument, which is not what the linker expects.
Here -Xlinker appears only once whereas it should be appear between each argument sent to the linker. So a ugly solution is to write:
-arch -Xlinker i386 -Xlinker -framework -Xlinker OpenGL -Xlinker -framework -Xlinker Carbon -Xlinker -framework -Xlinker Cocoa -Xlinker -framework -Xlinker IOKit
But if you find a way to configure Eclipse to use -Wl, instead of -Xlinker it would be better I think:
-Wl,option
Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.
Then you could use:
-arch,i386,-framework,OpenGL,-framework,Carbon,-framework,Cocoa,-framework,IOKit
Related
So, I am building a c++ executable(exe) on my Mac in Xcode. exe depends on frmwrk target which I am building as a Framework. To frmwrk target, I am linking a static library libA and libA further depends on static libB.
exe -> frmwrk -> libA -> libB
I am using symbols from libA and libB in my exe. However, I am getting linking error while building my exe. It is not able to find the symbols from libB. However, it is able to find the symbols from libA.
It looks like symbols of libB are only visible in frmwrk and not outside. Is there a way to expose symbols of libB to whoever links to frmwrk. In CMake, we have option to specify PUBLIC/PRIVATE dependency but I couldn't find in Xcode.
I debugged for hours but couldn't find any solutions. Can anybody help?
Here is my linker command for frmwrk
Ld /Users/vmangal/my/project/BuildResults/bin/Frameworks/Debug/Intel_64_libcpp/frmwrk.framework/Versions/A/frmwrk normal (in target 'myfrm_Debug' from project 'Project')
cd /Users/vmangal/my/project/Build/Toolkit/Mac
-filelist
/Users/vmangal/my/project/BuildResults/obj/myfrm/myfrm.build/Default/myfrm_Debug.build/Objects-normal/x86_64/frmwrk.LinkFileList -exported_symbols_list
/Users/vmangal/my/project/BuildResults/obj/myfrm/myfrm.build/Default/myfrm_Debug.build/DerivedSources/myfrm.exp -install_name u/executable_path/../Frameworks/frmwrk.framework/Versions/A/frmwrk -dead_strip -Xlinker -object_path_lto -Xlinker
/Users/vmangal/my/project/BuildResults/obj/myfrm/myfrm_Debug/myfrm.build/Default/myfrm_Debug.build/Objects-normal/x86_64/frmwrk_lto.o
-Xlinker -no_deduplicate -stdlib\=libc++ -fobjc-link-runtime -Xlinker -search_paths_first -lz -single_module -lPDCore -Xlinker -no_data_in_code_info
***Here is linking libA***
/Users/vmangal/my/project/pdfl_to_t5_approach_4/pdfTools/adobe/BuildResults/lib/debug/pdflib/Intel_libcpp/libA.a
-framework System -framework AppKit -framework QuickLook -Xlinker -no_adhoc_codesign -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/vmangal/my/project/obj/myfrm/myfrm_Debug/myfrm.build/Default/myfrm_Debug.build/Objects-normal/x86_64/frmwrk_dependency_info.dat -o /Users/vmangal/my/project/BuildResults/bin/Frameworks/Debug/Intel_64_libcpp/frmwrk.framework/Versions/A/frmwrk
Here is the linker command for exe
Ld /Users/vmangal/my/project/project/mac/debug/exe.app/Contents/MacOS/exe normal (in target 'exe.Debug' from project 'exe.mp')
cd /Users/vmangal/my/project/project/mac
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk
-L/Users/vmangal/my/project/project/mac/debug -L..
-L../../../../../../../../../usr/lib
-F/Users/vmangal/my/project/project/mac/debug
-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
-F/Users/vmangal/my/project/Public/Libraries/Mac/intel_64_libcpp/debug
-filelist
/Users/vmangal/my/project/project/mac/build/exe.mp.build/exe.Debug.build/Objects-normal/x86_64/exe.LinkFileList -Xlinker -no_pie -Xlinker -rpath -Xlinker u/executable_path/../Frameworks -Xlinker -object_path_lto -Xlinker
/Users/vmangal/my/project/project/mac/build/exe_SDK.mp.build/exe_SDK.Debug.build/Objects-normal/x86_64/exe_SDK_lto.o -Xlinker -no_deduplicate -stdlib\=libc++ -Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind -Wl,-no_data_in_code_info -Wl,-no_function_starts -framework CoreServices -framework ApplicationServices -framework Foundation -framework AppKit
***Here is linking frmwrk***
-framework frmwrk
-lxml2.2 -lz.1 -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker
/Users/vmangal/my/project/project/mac/build/exe_SDK.mp.build/exe_SDK.Debug.build/Objects-normal/x86_64/exe_SDK_dependency_info.dat -o /Users/vmangal/my/project/project/mac/debug/exe_SDK.app/Contents/MacOS/exe
Here is the creation command of libA:
Libtool /Users/vmangal/my/project/BuildResults/lib/debug/Intel_libcpp/libA.a normal (in target 'libA_debug_libcpp' from project 'Cos')
cd /Users/vmangal/my/project/Build/Cos/Mac
export MACOSX_DEPLOYMENT_TARGET\=10.15
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -D -syslibroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk
-L/Users/vmangal/my/project/BuildResults/lib/debug/pdflib/Intel_libcpp -filelist
/Users/vmangal/my/project/BuildResults/obj/Cos/libA_debug_libcpp/Cos.build/Default/libA_debug_libcpp.build/Objects-normal/x86_64/Cos.LinkFileList
***Here is linking libB***
/Users/vmangal/my/project/t5/xcode/build/Debug/libB.a
-dependency_info /Users/vmangal/my/project/pBuildResults/obj/Cos/libA_debug_libcpp/Cos.build/Default/libA_debug_libcpp.build/Objects-normal/x86_64/Cos_libtool_dependency_info.dat -o /Users/vmangal/my/project/BuildResults/lib/debug/Intel_libcpp/libA.a
I have added the linker command in question.
I have added Here is linking tag to show where my libraries appear in command.
This is the order in which linking takes place:
exe -> frmwrk -> libA -> libB
Also, when I run nm command on frmwrk, I can see all symbols which linker is complaining about.
I'm compiling an old version of OGRE ON CMake 3.6 to see if I can compile or revive an old piece of software, and Boost is one of the dependencies for OGRE. It's essentially for multi-threading and without it, OGRE 1.9.0 builds completely fine on the macOS 12.0 SDK but fails macOS 10.8 SDK (specified in ZSH as -DCMAKE_OSX_DEPLOYMENT_TARGET but that's another issue for later).
The CMake command: cmake -DOGRE_CONFIG_DOUBLE=ON -DOGRE_BUILD_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_PREFIX_PATH=/usr/local (yes, I'm compiling x86_64 on a arm64 machine running macOS 12.1 & XCode 13.1 if it matters)
When I build OGRE on the 12.0 SDK with Boost support (all is found here), it successfully checks for all libraries. As a note, Boost also has the atomic library but it's only needed as .hpp files and not an actual .a or whatever-lib file format CPP uses. Compiling OGRE goes all well until I see this dreaded message:
Copying OS X content lib/macosx/Ogre.framework/Versions/1.9.0/Resources/ogrelogo.png
28 warnings generated.
21 warnings generated.
[ 44%] Linking CXX shared library ../lib/macosx/Ogre.framework/Ogre
> ld: library not found for -latomic <
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Key questions: What is this atomic library? Is it only on an older SDK? Is it the hpp files? Here is the linker command shortened to where I think is the most important parts
cd /Users/meh/Downloads/project/ogre-1-9-0/OgreMain && /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/OgreMain.dir/link.txt --verbose=1
/usr/bin/clang++ -msse -stdlib=libc++ -std=c++11 -Wall -Winit-self -Wno-overloaded-virtual -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers -Wno-long-long -O3 -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -dynamiclib -Wl,-headerpad_max_install_names -framework AGL -framework IOKit -framework Cocoa -framework Carbon -framework OpenGL -framework CoreVideo -compatibility_version 1.9.0 -current_version 1.9.0 -o ../lib/macosx/Ogre.framework/Versions/1.9.0/Ogre -install_name #executable_path/../Frameworks/Ogre.framework/Versions/1.9.0/Ogre (ALL THOSE OGRE .O FILES) -L/usr/local/lib /usr/local/lib/libboost_thread.a /usr/local/lib/libboost_date_time.a /usr/local/lib/libboost_system.a /usr/local/lib/libboost_chrono.a /usr/local/lib/Release/libFreeImage.a /usr/local/lib/Release/libzziplib.a /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/lib/libz.tbd -latomic
I had to play around with the CMake file to not error listed as:
framework AGL
-stdlib=libc++ -std=c++11
I've done research and atomic shows up in C++11 so that shouldn't be a problem? There's some include files under the SDK but definitely none under /usr/local/lib... (I will have to add -L/usr/local/include as a prefix to -latomic later)
I'm trying to start a project in XCode 8 using wxWidgets 3.1.0 on OS X 10.11
After downloading wxWidgets-3.1.0 I've built and make everything according to the /docs/osx/install.txt
Now I tried to create a new project and followed their guide: https://wiki.wxwidgets.org/Creating_Xcode_projects_for_wxWidgets_applications
I followed almost every step exactly as instructed. (Static and Debug)
I didn't find the Summary Tab and a Choose Info.plist File Button, I chose it over General under Identity (which may be the same)
Then I tried to compile and run.
I'm getting Warnings and 1 Error.
Warning: Telling me to check dependencies
wxcocoa.xcconfig line 3: Unable to find included file "wx.xcconfig"
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file '/Users/me/Desktop/git/xcode/wx_mac_xcode/Info_cocoa.plist'.
Error:
Ld /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug/Static.app/Contents/MacOS/Static normal x86_64
cd /Users/me/Desktop/git/xcode/wx_mac_xcode
export MACOSX_DEPLOYMENT_TARGET=10.5
/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/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug -F/Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug -filelist /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Intermediates/wx_mac_xcode.build/Debug/Static.build/Objects-normal/x86_64/Static.LinkFileList -Xlinker -rpath -Xlinker #executable_path/../Frameworks -mmacosx-version-min=10.5 -Xlinker -no_deduplicate -framework WebKit -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework OpenGL -framework QTKit -framework WebKit -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework OpenGL -framework QTKit -lz -stdlib=libstdc++ -lwx_osx_cocoa_static -Xlinker -dependency_info -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Intermediates/wx_mac_xcode.build/Debug/Static.build/Objects-normal/x86_64/Static_dependency_info.dat -o /Users/me/Library/Developer/Xcode/DerivedData/wx_mac_xcode-bhbnjqgpmqtgwxhfxmjhvrtjnraz/Build/Products/Debug/Static.app/Contents/MacOS/Static
ld: library not found for -lwx_osx_cocoa_static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Double checked every step, but don't know how to fix those dependencies.
Project and library are debug mode
Cheers
I'm almost done upgrading Cocos2D from 0.99.5 to 2.1, but I don't know how to resolve this error. This is what shows up as the error:
Ld /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator/Flying\ Adventure.app/Flying\ Adventure normal i386
cd /Users/Admin/Documents/EriksFiles/Erik/iPad/cocos2d/flyingAdventure/flyingAdventure_current
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
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/iPhoneSimulator7.0.sdk -L/Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator -F/Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator -filelist /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Intermediates/flyingAdventure.build/Debug-iphonesimulator/flyingAdventure1.build/Objects-normal/i386/Flying\ Adventure.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -all_load -ObjC -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -lcocos2d\ libraries -framework CoreText -framework GameKit -lz.1.2.5 -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework AudioToolbox -framework OpenAL -lz -framework AVFoundation -Xlinker -dependency_info -Xlinker /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Intermediates/flyingAdventure.build/Debug-iphonesimulator/flyingAdventure1.build/Objects-normal/i386/Flying\ Adventure_dependency_info.dat -o /Users/Admin/Library/Developer/Xcode/DerivedData/flyingAdventure-esbllafxkpvprvdfdsnfuyectjnh/Build/Products/Debug-iphonesimulator/Flying\ Adventure.app/Flying\ Adventure
ld: library not found for -lcocos2d libraries
Library not found for -lcocos2d libraries
Linker command failed with exit code 1 (use -v to see invocation)
Does it have to do with my Link Binary With Libraries? Here's what that looks like:
I need to create librtaudio.dylib, a dynamically loadable RtAudio library (http://www.music.mcgill.ca/~gary/rtaudio/). I'd like to write CFFI bindings (in SBCL) but I can't seem to compile a dylib that is loadable using CFFI. Here are the compiler and linker commands I'm using to create the dylib:
g++ -O2 -Wall -Iinclude -fPIC -DHAVE_GETTIMEOFDAY -D__MACOSX_CORE__ -c RtAudio.cpp -o RtAudio.o
g++ -dynamiclib -install_name /usr/local/lib/librtaudio.dylib -lSystem -compatibility_version 1.0 -current_version 1.0 RtAudio.o -o librtaudio.dylib -lpthread -framework CoreAudio -framework CoreFoundation
It seems that CFFI's C++ support is not adequate to load RtAudio, as it is a C++ lib. A workaround is to write a C wrapper around RtAudio and then write bindings to the wrapper.