Reputation: 3024
I am trying to compile an FLTK program (http://www.fltk.org/index.php) on Mac OSX Mavericks. All the .h packages compile just fine, but I receive the following error:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried both g++
and clang++ -stdlib=libstdc++
to compile the program, but received the same error both times.
I would greatly appreciate any input on this issue to eliminate this error message.
Upvotes: 2
Views: 2559
Reputation: 1
brew install fltk
fltk-config --compile ./example_file.cpp
./example_file
Upvotes: 0
Reputation: 8890
This is what worked for me:
#!/bin/bash
rm ./a.out
clang++ main.cpp -o a.out -std=c++17 -stdlib=libc++ \
-I/usr/include/fltk-1.3.8/FL \
-L/usr/local/lib \
$(fltk-config --ldflags) \
&& ./a.out
Upvotes: 0
Reputation: 939
You want to use the fltk-config
script but it isn't clear how to use it generally form their documentation. This is a general form that I use and what it is actually doing:
From the command line you can compile like this (this assumes you need the image libraries, opengl libraries and wish to link statically [half the point of FLTK])
g++ file1.cpp file2.cpp `fltk-config --use-forms --use-gl --use-images --ldstaticflags --cxxflags` -o output
This is equivalent to
g++ file1.cpp file2.cpp -I/usr/local/include -I/usr/local/include/FL/images -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT /usr/local/lib/libfltk_images.a /usr/local/lib/libfltk_png.a -lz /usr/local/lib/libfltk_jpeg.a /usr/local/lib/libfltk_gl.a -framework AGL -framework OpenGL -framework ApplicationServices /usr/local/lib/libfltk_forms.a /usr/local/lib/libfltk.a -lpthread -framework Cocoa -o output
So if you make sure the libraries are in /usr/local/lib and the headers in /usr/local/include that should work...
fltk-config
is just a script that comes in the fltk-1.3.2 (or whatever) folder. Building FLTK from the make file should add that to your path. If not copy it or direct it to wherever it is. It does make me wonder though: have you definitely built the libraries?
Upvotes: 3