I'm trying to compile the following
#include <GLFW/glfw3.h>
int main()
{
glfwInit();
return 0;
}
just to verify that my GLFW installation is working. I use the terminal with
clang++ -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -I/opt/local/include/ test.c
but I receive a linker error for the glfwInit function:
Undefined symbols for architecture x86_64:
"_glfwInit", referenced from:
_main in test-d8c21e.o
ld: symbol(s) not found for architecture x86_64
I have installed glfw with sudo port install glfw and followed every possible tutorial I've found. I can verify that the libglfw.dylib file can be found at /opt/local/lib/ as (I think) it should.
Any suggestions?
You need to link with GLFW[3] as well, e.g., add:
-L/opt/local/lib -lglfw3
If you have the pkgconfig port installed, you can also take advantage of that with:
clang `pkg-config glfw3 --cflags` test.c -o test \
`pkg-config glfw3 --static --libs`
You may not need the --static flag if you have: libglfw3.dylib, as opposed to using: libglfw3.a, but it doesn't hurt.
If you are using Xcode, you must add the libglfw3.a library when linking binaries.
Heres the trick
Show hidden folders. Paste this into terminal: defaults write com.apple.finder AppleShowAllFiles YES
Relaunch a finder window and navigate to Macintosh HD\usr
Drag the usr folder to the "Favorites" side in the terminal
In xcode, click the add "+" to link binaries, then click "Add Other"
navigate to the libglfw3.a and add it!
If it still does not work, here are some instructions that helped me.
https://engineering-game-dev.com/2013/08/14/glfw-compiling-source-and-creating-an-xcode-project/comment-page-1/#comment-1400
Related
I have been working my way through the OpenGL-tutorial.org tutorial series. All has been working fine, however I have not been able to get Tutorial 5 to work in my playground executable, though it does work when run from the example tutorial 5 executable. This is true even when I copy and paste the example code over.
I receive the following errors:
Undefined symbols for architecture x86_64:
"loadDDS(char const*)", referenced from:
_main in playground.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Below is the link log:
Ld playground/playground normal x86_64
cd /Users/RufusVijayaratnam/rufus/Coding/ogl-master
/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/MacOSX10.15.sdk -L/Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground -F/Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground -filelist /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground_lto.o -Xlinker -no_deduplicate -Wl,-search_paths_first -Wl,-headerpad_max_install_names -framework OpenGL -framework OpenGL /Users/RufusVijayaratnam/rufus/Coding/OpenGL/external/glfw-3.1.2/src/Debug/libglfw3.a /Users/RufusVijayaratnam/rufus/Coding/OpenGL/external/Debug/libGLEW_1130.a -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo -Xlinker -dependency_info -Xlinker /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground_dependency_info.dat -o /Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground/playground
So the error appears to be that when the function loadDDS() is called that it is not found. I am unsure as to why this is. The function is declared in texture.ccp which is in a folder (called 'common'), along with texture.hpp. texture.hpp has the code below:
#ifndef TEXTURE_HPP
#define TEXTURE_HPP
// Load a .DDS file using GLFW's own loader
GLuint loadDDS(const char * imagepath);
#endif
In playground.cpp there is:
include<texture.hpp>
Why can't loadDDS() be found, even though I have set the working directory of the playground function to the same as that for Tutorial 5, and the code in playground.ccp and 'tutorial05.ccp' is exactly the same?
for the playground executable (doesn't work)
# User playground add_executable(playground
playground/playground.cpp
common/shader.cpp
common/shader.hpp )
and finally for tutorial 5 (does work)
# Tutorial 5
add_executable(tutorial05_textured_cube
tutorial05_textured_cube/tutorial05.cpp
common/shader.cpp
common/shader.hpp
common/texture.cpp
common/texture.hpp
So I'm making the educated guess that loadDDS() is implemented in texture.cpp, and since you did not add this file, it won't be compiled, and the resulting object file won't be linked, and the symbol will just not be found.
Sorry about english mistakes) Please help. I try build v8 engine from "Hellow world" example. It will be embedded on my base project, so i am need build it with Cmake, (system is macOS Sierra). I compiled v8 engine (build libraries by default stored in out directory) and i have following file system structure:
screen file system
As showed in example it later most build with this make expression :
g++ -I. hello_world.cpp -o hello_world -Wl,--start-group out/x64.release/obj.target/{tools/gyp/libv8_{base,libbase,external_snapshot,libplatform},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -ldl -pthread -std=c++0x
also, please look at my CMakeLists.txt file:
screen CMakeLists.txt
On build i have the following error output:
ld: symbol(s) not found for architecture x86_64
I solved problem, and for future i write my steps, how build V8 on macOS:
Build v8 engine without snapshot and as shared library for native platform: sudo make library=shared snapshot=off native;
Compile with clang (gcc throw error, like "undefined symbol for architecture..." etc ) but clang on mac compiles fine;
Copy from your ./out directory files with *./dylib to usr/local/lib
Recently I updated to XCode Version 8.0 (8A218a) on El Capitan (OS X 10.11 using Macports 2.3.4), and ever since, I have been getting the following link error when I try to compile my project inside Qt Creator.
/opt/local/bin/g++-mp-5 -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.8 -Wl,-rpath,/Users/zero/builds/Qt5.7.0/5.7/clang_64/lib -o uniMR.app/Contents/MacOS/uniMR ALL_OBJECT_FILES_GO_HERE.o -F/Users/zero/builds/Qt5.7.0/5.7/clang_64/lib -L/opt/local/lib -L/usr/local/lib -funit-at-a-time -fopenmp -lmlpack -larmadillo -framework CoreFoundation -DNDEBUG -lpthread -lALL_ITK_LIBS_GO_HERE -framework QtOpenGL -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework QtXml -framework OpenGL -framework AGL
**ld: unexpected token: !tapi-tbd-v2 file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [uniMR.app/Contents/MacOS/uniMR] Error 1**
I am compiling the main project with gcc 5.4 (not clang) inside QtCreator (Qt 5.7), and all my dependent libraries (ITK, BOOST, etc) are compiled using gcc 5.4 as well. I also recompiled all my dependent libraries after upgrading XCode, but that did not help either. I could find only one post that is related to the error I am seeing, but it doesnt seem useful:
https://trac.macports.org/ticket/51701
All was fine before I upgraded XCode. Now I am not sure how to fix the issue. I would appreciate any help on this. Thanks.
UPDATE:
This doesnt seem like a problem with any of the external libraries I am linking with. This is what I did. I created a new "QT widgets application" in QtCreator, and chose to compile with gcc5. I get the same error ld: unexpected token: !tapi-tbd-v2. If I switch to clang, then there is no error.
I had this "ld: unexpected token: !tapi-tbd-v2" error building an unrelated project and was able to solve it by editing the .tbd file for the framework that was giving the error.
For me that file was:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate.tbd
I simply removed the entire line "--- !tapi-tbd-v2" while building, and then put it back once finished.
had yesterday the same problem. I had XCode 7.3 and 8 on my system. Removing 7.3 and moving 8 into the apps location solved the problem.
I had the same problem. I used macport's GCC 6 as compiler and linker. It seems the GCC doesn't understand the new tbd format. In the MacOSX SDK path, there are now only these tbd text files which contain info about the real dylib libraries. So I just symlinked the real libraries to the SDK paths beside their tbd files. Then GCC can directly use the real libraries without parsing tbd files.
Here is a script for creating those symlinks:
https://gist.github.com/michalfapso/9abdbd5669bfdc4cd1a2179824d299e9
I had the same problem while compiling with opam.
The workaround was PATH=/usr/bin:$PATH, thus gcc will resolve to the default /usr/bin/gcc which is clang on macOS.
I have recently installed SFML 2.1 and am trying to compile and run from the terminal, NOT Xcode, the sample program that they have on their website at http://www.sfml-dev.org/tutorials/2.0/start-linux.php.
Path to where I installed SFML:
/Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal
However, I keep getting the error of:
Undefined symbols for architecture x86_64:
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in window-48cb4a.o
After googling it, I came across this question: SFML 2.1 RenderWindow linking error
In the accepted answer, the person said that if I wanted to use g++, I had to download the "GCC" version. So, I proceeded to download the GCC - universal 32+64 bits (OS X 10.5+) version and then followed the instructions for installing and compiling SFML on linux, since there were none for mac (http://www.sfml-dev.org/tutorials/2.0/start-linux.php) by doing the following:
Since I had installed SFML in a non-standard location, I told my compiler where to find the header files like so:
-I /Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/Frameworks/SFML.framework/Headers
I also had to tell my compiler where to find the SMFL libraries:
-L /Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib
I needed to also tell the library loader where to find the SFML libraries from:
export LD_LIBRARY_PATH=/Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib
Then, I put the sfml-audio.framework, sfml-window.framework, sfml-graphics.framework, sfml-network.framework, and sfml-system.framework in my Frameworks directory (/Library/Frameworks).
Finally, I tried to compile my program in the following ways:
g++ window.cpp -I /Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/Frameworks/SFML.framework/Headers/SFML -L /users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib -framework sfml-graphics -framework sfml-window -framework sfml-system
g++ window.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system
But, I keep getting the same error. I have continued to google the error, but all I keep getting are questions where people are using Xcode and not the terminal. Any help would be greatly appreciated!
I figured it out at last! First off, as Joachim Pileborg pointed out, I need to install the clang version of SFML for mac since I was using g++ to compile which is clang++ in disguise, as Joachim Pileborg also pointed out. Next, I had to go through the instructions again for setting up SFML with Linux (http://www.sfml-dev.org/tutorials/2.0/start-linux.php).
However, the icing on the cake was when I read this question:
OSX GCC how to specify sfml library source?
...and this question:
FreeType error when building in XCode
...which got me thinking: maybe I should try moving my freetype.framework folder (which can be found in the extlibs directory) into my /Library/Frameworks directory. Once I did this and compiled using
g++ window.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system
It compiled and ran successfully!!! I am very happy now!
i added new framework(3rd party) and build.
Unfortunately, since the execution was not.
How do I solve this problem?
The whole four nights were spent.:(
Ld /Users/hansehee/Library/Developer/Xcode/DerivedData/iBaseballManager-dbrtdyfdzzunktexlyibuzjbftoy/Build/Products/Distribution-iphoneos/iBaseballManager.app/iBaseballManager normal armv7s
cd /DevLibs/BaseballManager_KOR/iBaseballManager
setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -L/Users/hansehee/Library/Developer/Xcode/DerivedData/iBaseballManager-dbrtdyfdzzunktexlyibuzjbftoy/Build/Products/Distribution-iphoneos -L/DevLibs/BaseballManager_KOR/iBaseballManager/Classes/BaseballManager/kakaoUtil/kakao-ios-sdk -F/Users/hansehee/Library/Developer/Xcode/DerivedData/iBaseballManager-dbrtdyfdzzunktexlyibuzjbftoy/Build/Products/Distribution-iphoneos -filelist /Users/hansehee/Library/Developer/Xcode/DerivedData/iBaseballManager-dbrtdyfdzzunktexlyibuzjbftoy/Build/Intermediates/iBaseballManager.build/Distribution-iphoneos/iBaseballManager_Device.build/Objects-normal/armv7s/iBaseballManager.LinkFileList -dead_strip -fobjc-link-runtime -miphoneos-version-min=6.0 -framework StoreKit -framework SystemConfiguration -framework CoreData -weak_framework AdSupport -framework MediaPlayer -framework CoreTelephony -framework Security -lzlib -lstdc++ -lCxImage -lj2k -ljasper -lkakao-ios-sdk-i386-armv7-armv7s -ljbig -ljpeg -lpng -ltiff -framework AudioToolbox -framework AVFoundation -framework Foundation -framework UIKit -framework CoreGraphics -framework OpenAL -framework OpenGLES -framework QuartzCore -liClet -Xlinker -dependency_info -Xlinker /Users/hansehee/Library/Developer/Xcode/DerivedData/iBaseballManager-dbrtdyfdzzunktexlyibuzjbftoy/Build/Intermediates/iBaseballManager.build/Distribution-iphoneos/iBaseballManager_Device.build/Objects-normal/armv7s/iBaseballManager_dependency_info.dat -o /Users/hansehee/Library/Developer/Xcode/DerivedData/iBaseballManager-dbrtdyfdzzunktexlyibuzjbftoy/Build/Products/Distribution-iphoneos/iBaseballManager.app/iBaseballManager
ld: library not found for -lzlib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Remove the reference to the library and add it again, it will solve the problem.
Use xcworkspace it will solve your problem.
I also faced same once I install cocoa pods; Close and launch with xcworkspace again will solve your problem.
Make sure you have added the necessary search path for your library in Library Search Paths in Build Settings.
There should be something like:
${SOURCE_ROOT}/Framework/Classes
For .a files you need to set Target Dependencies in Build Phases in section.
Just click "+" and add your .a file there.
Had the same problem and none of these answers fix it for me.
Problem was Pod project in workspace had the following config:
Build Active Architecture Only: YES
For that reason, when I wanted to build for i386 (Simulator), XCode did not build Pods projects, so it could not meet dependencies. As soon as I changed it to NO it started working
If anyone is here looking specifically for the "library not found for -lPods" error, this was solved by opening the workspace instead of the xcodeproject. Searching google for library not found for -lPods without quotes turns this SO post as the first result, whereas if you wrap the search in quotes you'll get a post with the answer I just gave.
I changed -all_load to -force_load
In Xcode goto select your project
Build Settings -> Search Paths -> Library Search Paths set the path with /usr/local/lib
note : make sure that you have added dylib at frameworks
OS X 10.11 Xcode7.0.1
my case:
library not found for -lPods-BlocksKit
error:linker command failed with exit code 1(use -v to see invocation)
I delete all pod related content, add "$(inherited)" then fix it.
Other Linker Flags image
my case: use cocoapods, open xcworkspace, and meet "library not found for -lPods-AFNetworking" error.
my solution: Preference -> Location -> Derived Data, click "Advanced" button -> choose 'shared Folder'. (when meet error, the original location is Legacy).
None of the above solutions worked for me, so I downloaded the missing library:
https://github.com/danielctull-forks/GoogleAnalytics-SDK-iOS
7.3.1 Pods 1.0.0
Had same stuff today, after cocoapods update from 0.39.0 to 1.0.0.
Had an error : "ld: library not found -lPods".
I've got linked two "Pod" libs, accidentally. One was lPods, and other was lPods-ProjectName. I deleted "libPods.a: from Project>General>Linked Frameworks and Libraries
AND! I changed Pods>Build Active Build Architecture to NO, of course.
And it worked.