on Mac OS X Snow Leopard, I get the following error on make
gcc -g -O2 -fno-common -DPIC -Wall -Wmissing-prototypes stringbuffer.o shpopen.o dbfopen.o safileio.o getopt.o shp2pgsql-core.o shp2pgsql-cli.o ../liblwgeom/liblwgeom.a -o shp2pgsql -liconv -lm
Undefined symbols:
"_libiconv_open", referenced from:
_utf8 in shp2pgsql-core.o
"_libiconv_close", referenced from:
_utf8 in shp2pgsql-core.o
_utf8 in shp2pgsql-core.o
"_libiconv", referenced from:
_utf8 in shp2pgsql-core.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [shp2pgsql] Error 1
make: *** [loaderdumper] Error 2
What is the solution?
It seems there's some problem with libconv. Either it isn'l installed or it isn't correctly linked. Try installing it first.
Related
I am compiling a Makefile that needs -lrt library. My compiler is gcc-8 and I am currently working on a OSX Mojave OS.
I run from terminal using the make command, and I get the following error:
ld: library not found for -lrt
collect2: error: ld returned 1 exit status
make: *** [eflomal] Error 1
I have already tried to remove -lrt from LDFLAGS but in that case I get other errors:
/usr/local/Cellar/gcc/8.3.0/bin/gcc-8 -lm -lgomp -fopenmp eflomal.o -o eflomal
Undefined symbols for architecture x86_64:
"___kmpc_critical", referenced from:
_.omp_outlined..57 in eflomal.o
_.omp_outlined..61 in eflomal.o
"___kmpc_end_critical", referenced from:
_.omp_outlined..57 in eflomal.o
_.omp_outlined..61 in eflomal.o
"___kmpc_for_static_fini", referenced from:
_.omp_outlined. in eflomal.o
_.omp_outlined..57 in eflomal.o
_.omp_outlined..61 in eflomal.o
"___kmpc_for_static_init_4", referenced from:
_.omp_outlined. in eflomal.o
_.omp_outlined..57 in eflomal.o
_.omp_outlined..61 in eflomal.o
"___kmpc_fork_call", referenced from:
_main in eflomal.o
_align in eflomal.o
ld: symbol(s) not found for architecture x86_64
The Makefile header is the following:
export CXX=/usr/local/Cellar/gcc/8.3.0/bin/g++-8
export CC=/usr/local/Cellar/gcc/8.3.0/bin/gcc-8
CFLAGS=-Ofast -march=native -Wall --std=gnu99 -Wno-unused-function -g -fopenmp
# This is more suitable for debugging:
#CFLAGS=-Og -Wall --std=gnu99 -Wno-unused-function -g -fopenmp
#LDFLAGS=-lm -lrt -lgomp -fopenmp
LDFLAGS=-lm -lgomp -fopenmp -lrt
The first two lines are needed to use gcc compiler instead of clang (default on OSX).
Any idea on how to fix the problem?
I am running the test tcl module from the Swig tutorial site: http://www.swig.org/tutorial.html.
However, when I enter: gcc -shared example.o example_wrap.o -o example.so into the command line, it returns:
Undefined symbols for architecture x86_64:
"_TclFreeObj", referenced from:
__wrap_My_variable_get in example_wrap.o
__wrap_My_variable_set in example_wrap.o
.
.
.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions on what the issue may be?
I am stuck with this error:
mpif90 -o /Users/manfredo/Desktop/ED2/ED/build/ed_2.1-opt edmain.o -L/opt/local/lib/libgcc/ -lstdc++ -I/Users/manfredo/Desktop/ED2/ED/src/include -I/opt/local/include /Users/manfredo/Desktop/ED2/ED/build/ed_2.1-opt.a -lm -lz -L/opt/local/lib -lhdf5 -lhdf5_fortran
Undefined symbols for architecture x86_64:
"_calchydrosubsurface_", referenced from:
_ed_model_ in ed_2.1-opt.a(ed_model.o)
...
other similar errors
...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/manfredo/Desktop/ED2/ED/build/ed_2.1-opt] Error 1
make: *** [all] Error 2
I have tried adding -stdlib=libstdc++ or including the libraries lstdc++ or lstc++.6 as suggested here or here and I had already posted a question about the same error but still not able to fix it.
The compilation with mpif is needed. Any help will be appreciated.
I'm trying to compile something I've fetched off of github with gcc:
users-MBP:Chip-8-Emulator user$ gcc -o chip8 chip8.c
Undefined symbols for architecture x86_64:
"_SDL_Delay", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_Flip", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_GetKeyState", referenced from:
_chip8_execute in chip8-bc89fc.o
_chip8_prec in chip8-bc89fc.o
"_SDL_GetVideoSurface", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_Init", referenced from:
_chip8_prepare in chip8-bc89fc.o
"_SDL_LockSurface", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_PollEvent", referenced from:
_chip8_prepare in chip8-bc89fc.o
_chip8_prec in chip8-bc89fc.o
"_SDL_SetVideoMode", referenced from:
_chip8_prepare in chip8-bc89fc.o
"_SDL_UnlockSurface", referenced from:
_chip8_draw in chip8-bc89fc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The error seems to be an issue with the SDL library in this case, but I've had the exact same issue with several other little projects I treid to compile. Before compiling, I installed the SDL libs and checked they are there:
users-MBP:Chip-8-Emulator user$ ls /usr/local/lib/
...
libSDL-1.2.0.dylib
libSDL.a
libSDL.dylib
libSDLmain.a
...
After lots of Googling it seems I'm not the only one with this problem and I couldn't find solution that worked. It seems that osx doesn't include /use/local/lib in the default linker paths.
How can I fix this (a permanent solution would be welcome)?
EDIT
Following a suggestion from user Alex I tried with $ gcc -o chip8 -L/usr/local/lib chip8.c. The error and output is identical to the above.
You'll want to add -L/usr/local/lib -lSDL to your GCC invocation.
As for a more permanent solution, this is a convention of OS X, and strictly speaking /usr/local/lib is a non-standard installation location.
Ld /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug/c normal x86_64
cd /Users/ashutoshagarwal/Desktop/c
setenv MACOSX_DEPLOYMENT_TARGET 10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug -F/Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug -filelist /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Intermediates/c.build/Debug/c.build/Objects-normal/x86_64/c.LinkFileList -mmacosx-version-min=10.9 -framework Foundation -Xlinker -dependency_info -Xlinker /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Intermediates/c.build/Debug/c.build/Objects-normal/x86_64/c_dependency_info.dat -o /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug/c
Undefined symbols for architecture x86_64:
"_add_history", referenced from:
_main in main.o
"_readline", referenced from:
_main in main.o
_source 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)
I am getting Apple-Mach-O Linker (Id) Error, have sent hours trying to fix this one, Dunno what to do.
It looks like you are using the GNU readline and GNU history libraries, which are available, by default, on the mac in libedit.dylib:
$ nm /usr/lib/libedit.dylib | fgrep readline
0000000000009899 T _readline
000000000001f444 D _readline_echoing_p
000000000001f400 D _rl_readline_name
000000000001f3f8 D _rl_readline_version
$ nm /usr/lib/libedit.dylib | fgrep add_history
000000000000acbc T _add_history
(the T indicates that the symbol is in the library's text section).
Therefore you need to add -ledit to your linker command line. If you are using Xcode then you can add libedit.dylib to the list of libraries to link against or if you are using make then you probably have to edit the LIBS variable in your Makefile.
The error message:
Undefined symbols for architecture x86_64: "_add_history", referenced from: _main in main.o
"_readline", referenced from: _main in main.o _source 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)'
Tells you that the linker cannot find the symbols readline and add_history. Without seeing your source code, and the precise linker and compiler command-lines, it's hard to speculate the exact cause. A likely cause is that you failed to link with external libraries, or other modules of your program.