简体   繁体   中英

clang: error: linker command failed with exit code 1 (use -v to see invocation) - Qt Creator 3.3

Alright, I know that there are other posts on this error, but I can't seem to find one that fixes my problem. The issue is that when I try to build my C++ project in Qt Creator I get two errors: 1) symbol(s) not found for architecture x86_64 and 2) linker command failed with exit code 1 (use -v to see invocation) . The code builds and runs fine until I try to implement the FFT using the FFTW-3.3.4 library. The complete compiler output is:

14:55:10: Running steps for project RFdata...
14:55:10: Configuration unchanged, skipping qmake step.
14:55:10: Starting: "/usr/bin/make" 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr    /bin/clang++ -c -pipe -g -isysroot     /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDK    s/MacOSX10.9.sdk -mmacosx-version-min=10.7 -Wall -W -fPIE -DQT_CORE_LIB -    I../Qt/5.4/clang_64/mkspecs/macx-clang -I../RFdata -I../RFdata/fftw-    3.3.4/libbench2 -I../Qt/5.4/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -    I. -F/Users/Mike/Desktop/Qt/5.4/clang_64/lib -o main.o ../RFdata/main.cpp
../RFdata/main.cpp:93:22: warning: comparison of integers of different signs:     'long' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
  for (long i = 0; i < str.length(); ++i)                                                                                        //M:for loop that iterates through the length of the string and                                                                 //replaces each occurance of a ch1 with ch2
                   ~ ^ ~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr    /bin/clang++ -c -pipe -g -isysroot     /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDK    s/MacOSX10.9.sdk -mmacosx-version-min=10.7 -Wall -W -fPIE -DQT_CORE_LIB -    I../Qt/5.4/clang_64/mkspecs/macx-clang -I../RFdata -I../RFdata/fftw-    3.3.4/libbench2 -I../Qt/5.4/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -    I. -F/Users/Mike/Desktop/Qt/5.4/clang_64/lib -o display_vector.o     ../RFdata/display_vector.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr    /bin/clang++ -c -pipe -g -isysroot     /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDK    s/MacOSX10.9.sdk -mmacosx-version-min=10.7 -Wall -W -fPIE -DQT_CORE_LIB -    I../Qt/5.4/clang_64/mkspecs/macx-clang -I../RFdata -I../RFdata/fftw-    3.3.4/libbench2 -I../Qt/5.4/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -    I. -F/Users/Mike/Desktop/Qt/5.4/clang_64/lib -o convert_string.o     ../RFdata/convert_string.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr    /bin/clang++ -headerpad_max_install_names -Wl,-    syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/De    veloper/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.7 -Wl,-    rpath,/Users/Mike/Desktop/Qt/5.4/clang_64/lib -o RFdata main.o display_vector.o     convert_string.o   -F/Users/Mike/Desktop/Qt/5.4/clang_64/lib -    L/Users/Mike/Desktop/RFdata/fftw-3.3.4/libbench2/ -lbench2 -framework QtCore -    framework DiskArbitration -framework IOKit 
Undefined symbols for architecture x86_64:
  "_fftw_cleanup", referenced from:
      hilbert() in main.o
  "_fftw_destroy_plan", referenced from:
      hilbert() in main.o
  "_fftw_execute", referenced from:
      hilbert() in main.o
  "_fftw_plan_dft_1d", referenced from:
      hilbert() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see     invocation)
make: *** [RFdata] Error 1
14:55:11: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project RFdata (kit: Desktop Qt 5.4.0 clang     64bit)
When executing step "Make"
14:55:11: Elapsed time: 00:01.

I have absolutely no experience with linking libraries so any help would be absolutely amazing! I should probably show what my .pro file says since from what I can understand, adding the correct lines in the .pro file can be the difference between successfully linking to a library and not being as successful! .pro:

QT       += core

QT       -= gui

TARGET = RFdata
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp \
    display_vector.cpp \
    convert_string.cpp

HEADERS += \
    display_vector.h \
    convert_string.h

macx: LIBS += -L$$PWD/fftw-3.3.4/libbench2/ -lbench2

INCLUDEPATH += $$PWD/fftw-3.3.4/libbench2
DEPENDPATH += $$PWD/fftw-3.3.4/libbench2

macx: PRE_TARGETDEPS += $$PWD/fftw-3.3.4/libbench2/libbench2.a

So, I guess the overarching question, though I realize it is a very general and possibly simple one, is how do I go about successfully linking the fftw-3.3.4 library to my c++ project in Qt creator 3.3 on my mac (OSX 10.9.5)????? This has been driving me insane!

It looks like you are trying to link a 32bit library into a 64bit executable. Either look for a 64bit library or compile it as a 32bit program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM