i am getting the following linker error when compiling our Qt project.
We do not use qmake. We use autoconf & automake..
Now porting to Mac brings the follwoing error:
I have tried using Qt-SDK and by compiling Qt by myself... Neither worked :(
Maybe somebody has an idea?
/bin/sh ../../libtool --tag=CXX --mode=link clang++ -g -O2 -Wl,-rpath -
Wl,/space/dev-libs/instantclient_10_2 -Wl,-rpath -Wl,/space/dev-libs/boost_1_53/lib -v -o showtime showtime-application_resources.o showtime-main.o cmdline.o ../../atcaf/atcafgui/libatcafgui.la
libtool: link: clang++ -g -O2 -Wl,-rpath -Wl,/space/dev-libs/instantclient_10_2 -Wl,-rpath -Wl,/space/dev-libs/boost_1_53/lib -v -o showtime showtime-application_resources.o showtime-main.o cmdline.o -Wl,-bind_at_load ../../atcaf/atcafgui/.libs/libatcafgui.a -L/usr/local/Qt-5.0.1/lib /usr/local/Qt-5.0.1/lib/libQt5Widgets.dylib /usr/local/Qt-5.0.1/lib/libQt5Gui.dylib /usr/local/Qt-5.0.1/lib/libQt5Sql.dylib /usr/local/Qt-5.0.1/lib/libQt5Xml.dylib /usr/local/Qt-5.0.1/lib/libQt5XmlPatterns.dylib /usr/local/Qt-5.0.1/lib/libQt5Network.dylib /usr/local/Qt-5.0.1/lib/libQt5Core.dylib -L/space/dev-libs/log4cxx-dfs/lib /space/dev-libs/log4cxx-dfs/lib/liblog4cxx.dylib -L/usr/lib -laprutil-1 -lexpat -liconv -lpq -lsqlite3 -lldap -llber -lapr-1 -lpthread -L/space/dev-libs/boost_1_53/lib -lboost_python -lpython2.6 -L/space/dev-libs/instantclient_10_2 -lclntsh -lz
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.7.4 -o showtime -lcrt1.10.6.o -L/usr/local/Qt-5.0.1/lib -L/space/dev-libs/log4cxx-dfs/lib -L/usr/lib -L/space/dev-libs/boost_1_53/lib -L/space/dev-libs/instantclient_10_2 -rpath /space/dev-libs/instantclient_10_2 -rpath /space/dev-libs/boost_1_53/lib showtime-application_resources.o showtime-main.o cmdline.o -bind_at_load ../../atcaf/atcafgui/.libs/libatcafgui.a /usr/local/Qt-5.0.1/lib/libQt5Widgets.dylib /usr/local/Qt-5.0.1/lib/libQt5Gui.dylib /usr/local/Qt-5.0.1/lib/libQt5Sql.dylib /usr/local/Qt-5.0.1/lib/libQt5Xml.dylib /usr/local/Qt-5.0.1/lib/libQt5XmlPatterns.dylib /usr/local/Qt-5.0.1/lib/libQt5Network.dylib /usr/local/Qt-5.0.1/lib/libQt5Core.dylib /space/dev-libs/log4cxx-dfs/lib/liblog4cxx.dylib -laprutil-1 -lexpat -liconv -lpq -lsqlite3 -lldap -llber -lapr-1 -lpthread -lboost_python -lpython2.6 -lclntsh -lz -lstdc++ -lSystem /usr/bin/../lib/clang/3.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"QApplication::palette()", referenced from:
_main in showtime-main.o
"QApplication::commitData(QSessionManager&)", referenced from:
vtable for Application in libatcafgui.a(libatcafgui_la-Application.o)
"QApplication::saveState(QSessionManager&)", referenced from:
vtable for Application in libatcafgui.a(libatcafgui_la-Application.o)
"QAbstractItemView::dataChanged(QModelIndex const&, QModelIndex const&)", referenced from:
vtable for LogTableWWU in libatcafgui.a(libatcafgui_la-moc_LogTableWWU.o)
"QWidget::styleChange(QStyle&)", referenced from:
I had a similar problem when porting from Qt 4 to Qt 5. There were missing functions for QApplication::commitData() and QApplication::saveState().
I had derived a class from QApplication, in the header file I changed
#include <QtGui/QApplication>
to
#include <QApplication>
and this solved the problem.
I had the same problem, although mine was related to QWidget functions (e.g. QWidget::styleChange(QStyle&) or QWidget::fontChange(QFont const&)) rather than QApplication.
As suggested by koan, I looked for all the occurrences of
#include <QtGui/
in my project and replaced them with
#include <
which solved the problem. I tested this with both clang and g++ versions (5.0.1 and 5.0.2) and they both seem to work.
Note:
A number of solutions found on the web proposed to add
QT += widgets
to the qmake project (.pro) file, as this might be related to an existing bug. While I don't think that adding this is a problem, it did not solve this specific issue.
Related
I am new to macbook and apple computers in general, so I'm having a hard time making macbook pro recognize GLEW and GLFW. I installed both libraries with no problem, my includes are as follows: /usr/include/GL for glew.h, glxew.h and wglew.h. /usr/lib/ contains libGLEW.a the include and lib files for GLFW are in /usr/local/ I am using vim as a text editor and have a simple main.cpp program but it gives me an error that the glew.h cannot be found, any ideas why this is happening and how should I fix it?
#include <GL/glew.h>
#define GLFW_DLL
#include <GLFW/glfw3.h>
#include <stdio.h>
int main()
{
if (!glfwInit())
{
fprintf (stderr, "ERROR: could not start GLFW\n");
return 1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow (640, 480, "Hello Shaders", NULL, NULL);
if (!window)
{ fprintf(stderr, "ERROR: could not openwindow with GLFW3\n");
glgwTerminate();
return 1;
}
glfwMakeContextCurrent (window);
glewExperimantal = GL_TRUE;
glewInit();
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* version = glGetString(GL_VERSION);
printf("Renderer: %s\n", renderer);
printf("OpenGL version supported %s\n", version);
glEnable (DEPTH_TEST);
glDepthFunc (GL_LESS);
glfwTerminate();
return 0;
}
I am compiling with:
g++ -framework Cocoa -framework OpenGL -framework IOKit -o demo main.cpp -I include -I/sw/include -I/usr/local/include /usr/lib/libGLEW.a /usr/local/lib/libglfw3.a
Edit: moving the GL includes to /usr/local fixed compilation errors but now I get a linker error, any idea what can be done here?
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -I include -I /sw/include -I /usr/local/include -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/yuri13/Documents/shaders -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/b4/j5zrzg_n7hb205xs22z5f4qc0000gp/T/main-ea70be.o -x c++ main.cpp
clang -cc1 version 6.0 based upon LLVM 3.5svn default target x86_64-apple-darwin14.0.0
ignoring nonexistent directory "include"
ignoring nonexistent directory "/sw/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -o demo -framework Cocoa -framework OpenGL -framework IOKit /var/folders/b4/j5zrzg_n7hb205xs22z5f4qc0000gp/T/main-ea70be.o /usr/lib/libGLEW.a /usr/local/lib/libglfw3.a -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_CVDisplayLinkCreateWithCGDisplay", referenced from:
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
"_CVDisplayLinkGetNominalOutputVideoRefreshPeriod", referenced from:
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CVDisplayLinkRelease", referenced from:
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If you get an error related to including the header file, the compiler cannot find the header. You can pass the -v flag to GCC (incl. g++) or Clang (incl. clang++) to see information about where it’s looking for it.
As this forum post explains, if you receive these link errors:
Undefined symbols for architecture x86_64:
"_CVDisplayLinkCreateWithCGDisplay", referenced from:
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
"_CVDisplayLinkGetNominalOutputVideoRefreshPeriod", referenced from:
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CVDisplayLinkRelease", referenced from:
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
ld: symbol(s) not found for architecture x86_64
Then you probably need to link with the CoreVideo framework. If you’re compiling on the command line, you can use -framework CoreVideo.
Helllo, I have some code, that I'm trying to compile. The code runs well on Linux but I can't compile it on OSX.
In the makefile I use for Linux:
LD_FLAGS = -lcudart -L$(CUDA_HOME)/lib64
For Mac I try to use these flags:
LD_FLAGS = -lcudart -L$(CUDA_HOME)/lib
LD_FLAGS = -lm -F/Library/Frameworks -framework CUDA
CXXFLAGS = -O3 -g -m32 -I$(CUDA_HOME)/include
NVCC_FLAGS = -O3 -g -G -I$(CUDA_HOME)/include -arch=sm_11
This is the make output file:
mpic++ -c -o main.o main.cpp -O3 -m32 -I/Developer/NVIDIA/CUDA-5.0/include
/Developer/NVIDIA/CUDA-5.0/bin/nvcc -c -o kernel.o kernel.cu -O3 -I/Developer/NVIDIA/CUDA-5.0/include -arch=sm_11
ptxas /tmp/tmpxft_000026f4_00000000-5_kernel.ptx, line 146; warning : Double is not supported. Demoting to float
/Developer/NVIDIA/CUDA-5.0/bin/nvcc -c -o support.o support.cu -O3 -I/Developer/NVIDIA/CUDA-5.0/include -arch=sm_11
mpic++ main.o kernel.o support.o -o stencil-mpi -lcudart -L/Developer/NVIDIA/CUDA-5.0/lib
ld: warning: ld: warning: ignoring file kernel.o, file was built for i386 which is not the architecture being linked (x86_64): kernel.o
ignoring file main.o, file was built for i386 which is not the architecture being linked (x86_64): main.o
ld: warning: ignoring file support.o, file was built for i386 which is not the architecture being linked (x86_64): support.o
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [stencil-mpi] Error 1
This problem was caused by trying to mix 32 and 64 bit compilation between the CUDA and MPI toolchains. It was noted in comments that adding -m64 instead of -m32 for LD_FLAGS, CXXFLAGS, and NVCC_FLAGS produced a working 64 bit build.
The detail error message is below.
$ ./configure
$ make
then ...
/usr/share/apr-1/build-1/libtool --silent --mode=link /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -lssl -lcrypto -lpthread \
-o ab ab.lo -L/usr/lib -R/usr/lib -laprutil-1 -lexpat -liconv -lsqlite3 -lldap -llber -llber -L/usr/lib -R/usr/lib -lapr-1 -lpthread
Undefined symbols for architecture x86_64:
"_TLSv1_1_client_method", referenced from:
_main in ab.o
"_TLSv1_2_client_method", referenced from:
_main in ab.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
APR and apr-util are required dependencies.
So - before building httpd on Mac,
port install APR
port install apr-util
Solved this.
Additionally, you might have to set the 'OPENSSL_ROOT_DIR' variable to '/opt/local'.
You can do that by giving '-DOPENSSL_ROOT_DIR=/opt/local' as command line argument when executing cmake.
I try to compile program using boost with Clang++ on Mac OS X in Qt Creator. Everything goes fine: I have compiled boost and all program modules, but on the linkage stage clang cannot find any symbols:
Undefined symbols for architecture x86_64:
"_BIO_ctrl", referenced from:
boost::asio::ssl::detail::engine::map_error_code(boost::system::error_code&) const in session.o
.....
"boost::log::v2s_mt_posix::core::get()", referenced from:
INIT_LOG() in log.o
.....
qmake config:
CONFIG -= qt
CONFIG += console debug
TARGET = server
QMAKE_CXXFLAGS -= -mmacosx-version-min=10.6
QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7
QMAKE_LFLAGS -= -mmacosx-version-min=10.6
QMAKE_LFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7
Linking command is:
clang++ -headerpad_max_install_names -stdlib=libc++ -mmacosx-version-min=10.7 -o server main.o session.o log.o -L/Users/apple/Lib/boost_1_53_0/usr/lib -L/opt/local/lib -L/usr/lib -lssl -lboost_system -lboost_filesystem -lboost_date_time -lboost_thread -lboost_log_setup -lboost_log -lboost_chrono -lboost_program_options
If I rename *.dylib, it says that cannot find -lboost_*, so it really SEES library files.
With nm I can find, that symbols exist:
0000000000018ad0 T __ZN5boost3log11v2_mt_posix4core3getEv
I'm trying to create a lib with g++ 4.0.1, but it looks for _main (which deliberately isn't in the code). Must I put a _main in there or can I circumvent with some nifty switch? My current command line looks like:
g++ -shared -o mylib.so myobj1.o myobj2.o ...
On a sidenote I'm using g++ powerpc-apple-darwin9, but I'm guessing/hoping that this should be irrelevant. A more complete printout:
$g++ -O0 -ggdb -fPIC -D_DARWIN_C_SOURCE -D_STLP_THREADS -D_POSIX_PTHREAD_SEMANTICS -Istlport/stlport -Iutf8cpp -Ifreealut-1.1.0/include -Iode-0.11.1/include -Iode-0.11.1/ode/src -Iode-0.11.1/ode/src/joints -Iode-0.11.1/OPCODE -Iode-0.11.1/GIMPACT/include -Iode-0.11.1/ou/include -DPOSIX -D_XOPEN_SOURCE=600 -D_DEBUG -D_CONSOLE -DPNG_NO_ASSEMBLER_CODE -DdSingle -DdTLS_ENABLED=1 -DHAVE_CONFIG_H=1 -DLEPRA_WITHOUT_FMOD -framework OpenGL -framework CoreServices -framework OpenAL -DMAC_OS_X_VERSION=1050 -Wno-unknown-pragmas -o myfile.o -c myfile.cpp
$g++ -shared -framework OpenGL -framework AppKit -framework Cocoa -lobjc -lstlport -framework CoreServices -Lstlport/build/lib/obj/gcc/so -L. -Lopenal-soft-1.10.622 -Lfreealut-1.1.0/admin/VisualStudioDotNET/alut -L../Lepra -L../TBC -L../Cure -L../UiLepra -L../UiTBC -L../UiCure -L../Life -framework OpenAL -o libThirdParty.so myfile.o
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libThirdParty.so] Error 1
The solution is to upgrade the compiler. As stated by Adil, 4.1.2 seems to work. Myself, I upgraded to 4.3.4 and that worked great too.