"Apple Mach-O (id) linker" error when adding external libraries to project - sqlite

I added FMDB to my project then added the frameworks libsqlite3.dylib and libsqlite3.0.dylib, but I still get the build error. If I remove the FMDB classes from my project then it builds just fine. What other things should I check?
Detailed info on the error:
Ld /Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Products/Debug->iphonesimulator/iNROMockUp5.app/iNROMockUp5 normal i386
cd /iOSDev/Testing/iNROMockUp5
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH >"/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bi>n:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 >-isysroot >/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk ->L/Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Products/Debug-iphonesimulator ->F/Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Products/Debug-iphonesimulator -filelist >/Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Intermediates/iNROMockUp5.build/Debug->iphonesimulator/iNROMockUp5.build/Objects-normal/i386/iNROMockUp5.LinkFileList -mmacosx->version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -lsqlite3 -lsqlite3.0 -framework >MapKit -framework UIKit -framework Foundation -framework CoreGraphics -o >/Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Products/Debug->iphonesimulator/iNROMockUp5.app/iNROMockUp5
ld: duplicate symbol _main in /Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Intermediates/iNROMockUp5.build/Debug->iphonesimulator/iNROMockUp5.build/Objects-normal/i386/fmdb.o and >/Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Intermediates/iNROMockUp5.build/Debug->iphonesimulator/iNROMockUp5.build/Objects-normal/i386/main.o for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed >with exit code 1
ld: duplicate symbol _main in /Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Intermediates/iNROMockUp5.build/Debug->iphonesimulator/iNROMockUp5.build/Objects-normal/i386/fmdb.o and >/Users/gmi/Library/Developer/Xcode/DerivedData/iNROMockUp5->gjmgpakyszrgwbbxnkdxehexacxm/Build/Intermediates/iNROMockUp5.build/Debug->iphonesimulator/iNROMockUp5.build/Objects-normal/i386/main.o for architecture i386
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

Remove fmdb.m from your project and you will be fine.

Remove main.m from your project and you will be fine.

Related

build x264 failed on apple M1, No working C compiler found

Apple M1, clang
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
x264 version x264-snapshot-20191217-2245
configure
./configure --prefix=/tmp/ --enable-static
config.log
checking for -Werror=unknown-warning-option... yes
checking for -mdynamic-no-pic... yes
x264 configure script
Command line options: "--prefix=/tmp/" "--enable-static"
checking whether gcc works... no
Failed commandline was:
--------------------------------------------------
gcc conftest.c -Wall -I. -I$(SRCPATH) -mdynamic-no-pic -arch armv7 -Werror=unknown-warning-option -lm -arch armv7 -o conftest
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a, missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a (5 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libm.tbd, missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libm.tbd (3 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd (3 slices)
ld: dynamic main executables must link with libSystem.dylib for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--------------------------------------------------
Failed program was:
--------------------------------------------------
int main (void) { return 0; }
--------------------------------------------------
DIED: No working C compiler found.
x264 source snapshot tarballs have not been updated for a long time. You need to update x264 sources to a newer version: https://code.videolan.org/videolan/x264/
Apple Silicon support in x264 was added at the end of 2020.

Error while building R from source with gcc OpenMP support

I am trying to compile R in a Redhat linux environment on a HPC cluster. I have used environment modules to install recent versions of a number of tools including GCC 5.2.0. I cannot get R to build from the source. It fails with undefined reference to `GOMP_parallel'. When I compile with the --disable-openmp option it compiles fine.
array.o: In function `do_colsum':
array.c:(.text+0x5829): undefined reference to `GOMP_parallel'
collect2: error: ld returned 1 exit status
make[3]: *** [R.bin] Error 1
make[3]: Leaving directory `/scratch/kokul/240763.hpc5/R- 3.2.3/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/scratch/kokul/240763.hpc5/R- 3.2.3/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/scratch/kokul/240763.hpc5/R-3.2.3/src'
make: *** [R] Error 1
A couple of questions
What are the advantages of having openMP enabled, I am assuming this will enhance the performance?
How do I fix the error I encounter while building? Is this related to linking the correct library? -fopenmp is correctly used while building. libgomp.* files are also in the $LIBRARY_PATH and $LD_LIBRARY_PATH.
It might be a simple thing I am missing, but I have tried to search for a proper answer without success.
Advanced thanks for any help.
I am having the same problem:
gcc -Wl,--export-dynamic -fopenmp -L/usr/local/lib -o R.bin Rmain.o CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o arithmetic.o array.o attrib.o bind.o builtin.o character.o coerce.o colors.o complex.o connections.o context.o cum.o dcf.o datetime.o debug.o deparse.o devices.o dotcode.o dounzip.o dstruct.o duplicate.o edit.o engine.o envir.o errors.o eval.o format.o gevents.o gram.o gram-ex.o graphics.o grep.o identical.o inlined.o inspect.o internet.o iosupport.o lapack.o list.o localecharset.o logic.o main.o mapply.o match.o memory.o names.o objects.o options.o paste.o platform.o plot.o plot3d.o plotmath.o print.o printarray.o printvector.o printutils.o qsort.o radixsort.o random.o raw.o registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o sort.o source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o summary.o sysutils.o times.o unique.o util.o version.o g_alab_her.o g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o ls ../unix/*.o ../appl/*.o ../nmath/*.o ../extra/tre/libtre.a -L../../lib -lRblas -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -lgfortran -lm -lquadmath -lreadline -lpcre -llzma -lbz2 -lz -lrt -ldl -lm
array.o: In function do_colsum':
/home/myaccount/Downloads/R-patched/src/main/array.c:1437: undefined reference toGOMP_parallel'
collect2: error: ld returned 1 exit status
Makefile:144: recipe for target 'R.bin' failed
This is a configuration problem from R (autotools problem). My computer has both gcc 4.8 (came with OS) and the latest version gcc 5.2 (I build from source). The gcc 5.2 is located in /usr/local
I saw that R is mixing these two up, and not picking up the 5.2 library locations.
I changed the Makefile (this is only one time fix since the make file is generated by the autotool).
First go to src/main directory. Then edit the Makefile:
143 $(R_binary): $(R_bin_OBJECTS) $(R_bin_DEPENDENCIES)
144 $(MAIN_LINK) -o $# $(R_bin_OBJECTS) $(R_bin_LDADD)
Edite line 144:
144 $(MAIN_LINK) -o $# $(R_bin_OBJECTS) -L/usr/local/lib64 -lgomp $(R_bin_LDADD)
This fixed my problem. I had a hard time filing a bug with the R project. If the R developers saw this, could they fix this at the auto configure level? The auto probing just have to be a little bit smarter.

WKHTMLTOPDF with Patched QT Ubuntu 14.04 Errors during compiling

I am trying to compile the wkhtmltopdf with patched qt using these instructions and when i get to the make && make install it gives me an error has anyone else done this on Ubuntu 14.04? I can't figure out what to do from here.
these are the instructions i am following i know they are not for 14.04 but i hoped they would have worked https://gist.github.com/Zauberfisch/8773593
This is the error i get:
cd src/lib/ && make -f Makefile make[1]: Entering directory /temp/wkhtmltopdf/src/lib' rm -f libwkhtmltox.so.0.12.1 libwkhtmltox.so libwkhtmltox.so.0 libwkhtmltox.so.0.12 g++ -Wl,-O1 -Wl,-rpath,/temp/wkqt/lib -shared -Wl,-soname,libwkhtmltox.so.0 -o libwkhtmltox.so.0.12.1 ../../build/loadsettings.o ../../build/multipageloader.o ../../build/tempfile.o ../../build/converter.o ../../build/websettings.o ../../build/reflect.o ../../build/utilities.o ../../build/pdfsettings.o ../../build/pdfconverter.o ../../build/outline.o ../../build/tocstylesheet.o ../../build/imagesettings.o ../../build/imageconverter.o ../../build/pdf_c_bindings.o ../../build/image_c_bindings.o ../../build/moc_multipageloader_p.o ../../build/moc_converter_p.o ../../build/moc_pdfconverter_p.o ../../build/moc_imageconverter_p.o ../../build/moc_pdf_c_bindings_p.o ../../build/moc_image_c_bindings_p.o ../../build/moc_converter.o ../../build/moc_multipageloader.o ../../build/moc_utilities.o ../../build/moc_pdfconverter.o ../../build/moc_imageconverter.o ../../build/qrc_wkhtmltopdf.o -L/temp/wkqt/lib -lQtWebKit -lQtSvg -L/temp/wkqt/lib -L/usr/X11R6/lib -lQtXmlPatterns -lQtGui -lQtNetwork -lQtCore -lpthread /usr/bin/ld: ../../build/qrc_wkhtmltopdf.o: relocation R_X86_64_32 against.rodata' can not be used when making a shared object; recompile with -fPIC ../../build/qrc_wkhtmltopdf.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status make[1]: * [../../bin/libwkhtmltox.so.0.12.1] Error 1 make[1]: Leaving directory `/temp/wkhtmltopdf/src/lib' make: * [sub-src-lib-make_default-ordered] Error 2
I downloaded a binary from their site that already had the QT build and that fixed the issue for me. Thanks!

Error while testing QT test project

I have started using QT on Kubuntu. I first installed g++ via Package Manager. Then I installed QT 5.0.1. I then made a test project to check if everything is correct or not. Then I got following issues.
- cannot find -lGL
- collect2: error:Id returned 1 exit status
I saw in Compile Output
11:32:05: Running steps for project untitled2...
11:32:05: Configuration unchanged, skipping qmake step.
11:32:05: Starting: "/usr/bin/make" -w
make: Entering directory `/home/harsh/Desktop/untitled2-build-Desktop_Qt_5_0_1_GCC_64bit-Debug'
g++ -m64 -Wl,-rpath,/home/harsh/Qt5.0.1/5.0.1/gcc_64 -Wl,-rpath,/home/harsh/Qt5.0.1/5.0.1/gcc_64/lib -o untitled2 main.o mainwindow.o moc_mainwindow. -L/usr/X11R6/lib64 -L/home/harsh/Qt5.0.1/5.0.1/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [untitled2] Error 1
make: Leaving directory `/home/harsh/Desktop/untitled2-build-Desktop_Qt_5_0_1_GCC_64bit-Debug'
11:32:05: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled2 (kit: Desktop Qt 5.0.1 GCC 64bit)
When executing step 'Make'
Please help me fix these errors.
Qt != QT
The error tells you what is wrong, the compiler cannot find libGL.so. It's usually in /usr/lib64.

Qt 5.0 Build Warning

I have installed Qt 5.0 (the whole SDK) on Fedora 17. I have configured the compiler (GCC) and everything seems to be working fine, except that when I press "Ctrl-R" for having a demo of my GUI coding, I get the following error :
make: Entering directory `/home/Nisarg/Documents/Qt Projects/untitled-build-Desktop_Qt_5_0_1_GCC_32bit-Debug'
g++ -Wl,-rpath,/opt/Qt/5.0.1/gcc -Wl,-rpath,/opt/Qt/5.0.1/gcc/lib -o untitled main.o mainwindow.o moc_mainwindow.o -L/opt/Qt/5.0.1/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
**/usr/bin/ld: cannot find -lGL**
make: Leaving directory `/home/Nisarg/Documents/Qt Projects/untitled-build-Desktop_Qt_5_0_1_GCC_32bit-Debug'
collect2: error: ld returned 1 exit status
make: *** [untitled] Error 1
04:07:17: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled (kit: Desktop Qt 5.0.1 GCC 32bit)
When executing step 'Make'.
(The error above is that a file called -lGL is not found)
How do I go about solving this error ?
You will need to have the libGL development files installed. It's been awhile since I used Fedora, but check your package manager for a package named something like mesa-libGL-devel.

Resources