There are lots of threads that have similar questions, but many deal with c++ code and have c++ solutions. However, from what I gather on the various threads, I might be missing a library when gcc is trying to link libraries.
I don't know which library I need to include though, for JSON1 to build successfully.
For loading SQLite extensions, their official instructions on the Mac is:
gcc -g -fPIC -dynamiclib YourCode.c -o YourCode.dylib
So I have done:
$ gcc -g -fPIC -dynamiclib sqlite-src-3180000/ext/misc/json1.c -o json1
sqlite-src-3180000/ext/misc/json1.c:344:11: warning: implicit declaration of function
'sqlite3_value_subtype' is invalid in C99 [-Wimplicit-function-declaration]
if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){
^
sqlite-src-3180000/ext/misc/json1.c:501:3: warning: implicit declaration of function
'sqlite3_result_subtype' is invalid in C99 [-Wimplicit-function-declaration]
sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
^
2 warnings generated.
Undefined symbols for architecture x86_64:
"_sqlite3_result_subtype", referenced from:
_jsonArrayFunc in json1-5de683.o
_jsonExtractFunc in json1-5de683.o
_jsonObjectFunc in json1-5de683.o
_jsonQuoteFunc in json1-5de683.o
_jsonArrayFinal in json1-5de683.o
_jsonObjectFinal in json1-5de683.o
_jsonReturnJson in json1-5de683.o
...
"_sqlite3_value_subtype", referenced from:
_jsonAppendValue in json1-5de683.o
"_sqlite3_vsnprintf", referenced from:
_jsonPrintf in json1-5de683.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What am I missing?
This is my gcc details, if it helps:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Related
Given a very simple fortran (95) function and a very simple c++ call to the program, I should be able to compile the program using:
g++ -c main1.cpp
gfortran -c test.f95
g++ main1.o test.o -o run
However, here I get the following error:
ld: warning: object file (test.o) was built for newer macOS version (11.5) than being linked (11.0)
Undefined symbols for architecture arm64:
"hello_()", referenced from:
_main in main1.o
"__gfortran_st_write", referenced from:
_hello_ in test.o
"__gfortran_st_write_done", referenced from:
_hello_ in test.o
"__gfortran_transfer_character_write", referenced from:
hello in test.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here, adding a -v tag before the -o tag and after the -o tag and the exe run did not solve the problem, as suggested by the error message.
I am trying to compile a code that uses the FFTW libraries. I have installed these and have checked using lipo that they are installed for x86_64 architecture. However when I try to compile I get the following error
mpif90 -r8 -O3 -assume byterecl -u -I/usr/local/mpich2/include -I/usr/local/fftw_215_mpich2/include -L/usr/local/fftw_215_mpich2/lib -I./OBJ/ ./SRC/tt_main.f90 ./OBJ/xx_exter.o ./OBJ/tt_fft.o ./OBJ/tt_force.o ./OBJ/tt_init.o ./OBJ/tt_io.o ./OBJ/tt_les.o ./OBJ/tt_update.o ./OBJ/tt_stat.o ./OBJ/tt_mod.o ./OBJ/xx_mod.o -o turbo -ldfftw -ldrfftw -ldfftw_mpi -ldrfftw_mpi -lm
Undefined symbols for architecture x86_64:
"_rfftwnd_f77_mpi_", referenced from:
_fft3ds_ in tt_fft.o
_ifft3ds_ in tt_fft.o
"_rfftwnd_f77_mpi_create_plan_", referenced from:
_init_fft3d_ in tt_fft.o
"_rfftwnd_f77_mpi_local_sizes_", referenced from:
_init_fft3d_ in tt_fft.o
ld: symbol(s) not found for architecture x86_64
make[1]: *** [turb] Error 1
make: *** [turbo] Error 2
Can anyone help?
I am trying to compile dynamic lib in Mac OS X Mavericks, but when I try to link it, it says:
Undefined symbols for architecture i386:
"operator new(unsigned long, int, char const*, int)", referenced from:
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compile flags I use:
Wall -Wextra -m32 -march=pentium4 -arch i386 -fvisibility=hidden
tried with
-stdlib=libc++ -lstdc++ -lc++
not helping.
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Please help!
EDIT:
Ok, lack of attention:
ld: symbol(s) not found for architecture i386
So, figured out that this is only happening when -g flag is present :)
For release build there is no error.
The question that arises is why there is no debug information symbols on MacOS X for libc++ (operator new). Any clues?
I am trying to compile boost C++ using clang.
./b2 --prefix=~/boost --includedir=~/boost/include --libdir=~/boost/lib toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -isystem ~/libcxx/include/" linkflags="-stdlib=libc++ -L ~/libcxx/lib/"
When I see log file it gives error saying
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
__GLOBAL__I_a in exceptions.o
"boost::system::generic_category()", referenced from:
__GLOBAL__I_a in exceptions.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
my default clang is clang-mp-3.3. Can anyone please help me figure out what this problem is.
After searching for the reason of error in the web I found this which explain about compiling boost with clang. I am not sure why adding define=BOOST_SYSTEM_NO_DEPRECATED made it worked. Please do comment anyone who knows why it worked. I was then able to compile with no error but I still see some warnings but it worked for me for now.
The default clang I am using is (clang-mp-3.3)
$ clang -v
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
./bootstrap.sh --with-toolset=clang --without-libraries=mpi,python,graph_parallel
./b2 clean
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++" define=BOOST_SYSTEM_NO_DEPRECATED
I have succesfully compiled the LLVM kalidoscope examples in C.
Now I'm extending the code with:
#include "llvm/Support/CommandLine.h"
static cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input file>"), cl::Required);
int mail(...
now i compile using:
clang++ -g toy.cpp llvm-config --cppflags --ldflags --libs all -O3 -o toy
and after this change i receive the following error:
Undefined symbols for architecture x86_64:
"typeinfo for llvm::cl::GenericOptionValue", referenced from:
typeinfo for llvm::cl::OptionValueCopy<std::string> in toy-Pq1GSI.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What could be wrong, and how can i fix it?
Versions:
clang++ -v Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) Target: x86_64-apple-darwin12.2.0 Thread model: posix
brew info llvm llvm: stable 3.2 (bottled), HEAD http://llvm.org/ /usr/local/Cellar/llvm/3.2 (628 files, 106M) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/llvm.rb
==> Options
--all-targets Build all target backends
--universal Build a universal binary
--rtti Build with C++ RTTI
--shared Build LLVM as a shared library
--with-clang Build Clang C/ObjC/C++ frontend
==> Caveats Extra tools and bindings are installed in /usr/local/Cellar/llvm/3.2/share/llvm and /usr/local/Cellar/llvm/3.2/share/clang.
It seems that changing the compile command to this is a fix:
clang++ -g toy.cpp llvm-config --cxxflags --ldflags --libs -O3 -o toy