QuantLib 1.9 install on OS X - macos

The error clang: error: linker command failed with exit code 1 (use -v to see invocation)
on running the compile example, from http://quantlib.org/install/macosx.shtml,
g++ -I/opt/local/include/ -I/opt/local/include/boost BermudanSwaption.cpp \
-o bermudanswaption -L/opt/local/lib/ -lQuantLib
Error message is:
clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin16.1.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/opt/local/include
/opt/local/include/boost
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/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.12.0 -o bermudanswaption -L/opt/local/lib/ /var/folders/m3/39_h4bg52xzfv8800_zrkvrh0000gn/T/BermudanSwaption-a73fac.o -lQuantLib -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
......
"QuantLib::detail::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, QuantLib::detail::percent_holder const&)", referenced from:
calibrateModel(boost::shared_ptr<QuantLib::ShortRateModel> const&, std::__1::vector<boost::shared_ptr<QuantLib::CalibrationHelper>, std::__1::allocator<boost::shared_ptr<QuantLib::CalibrationHelper> > > const&) in BermudanSwaption-a73fac.o
_main in BermudanSwaption-a73fac.o
"QuantLib::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, QuantLib::Date const&)", referenced from:
QuantLib::InterestRateIndex::valueDate(QuantLib::Date const&) const in BermudanSwaption-a73fac.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 does this mean and why is LLVM invoked? I'm using latest Xcode, Mac OSX 10.12.1, familiar with python but not command line installs or compilation....

The error is very simple. You only compiled BermudanSwaption.cpp but you also need to compile the entire QuantLib. Otherwise, the linker can't find the implementation.

Related

Compile Fortran Function using gfortran: object file was built for newer macOS version than being linked

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.

How to connect OpenCV to Xcode?

The path:
/usr/local/include
/usr/local/lib
Outputs such an error:
Undefined symbols for architecture x86_64:
"cv::String::deallocate()", referenced from:
cv::String::~String() in main.o
cv::String::operator=(cv::String const&) 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)
How to fix this error?

Unable to build electron 1.6.2 on OSX

I build the electron app with following scripts:
script/bootstrap.py -v --target_arch x64
script/create-dist.py
The first one ends successfully, but the second one throws this error (from TeamCity log):
...skipped log entries
[02:56:38][Step 2/2]
[1315/1328] SOLINK "Electron Framework.framework/Versions/A/Electron Framework", POSTBUILDS
[02:56:38][Step 2/2]
FAILED: ../../vendor/llvm-build/Release+Asserts/bin/clang++ -shared -ObjC -stdlib=libc++ -Wl,-dead_strip -mmacosx-version-min=10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -arch x86_64 -L. -install_name #rpath/Electron\ Framework.framework/Electron\ Framework -Wl,-rpath,#loader_path/Libraries -F/Users/teamcity/buildAgent/work/e4f0eac9e33806e2/external_binaries -stdlib=libc++ -o "Electron Framework.framework/Versions/A/Electron Framework" #Electron_Framework.framework.rsp
[02:56:38][Step 2/2]
ld: warning: ignoring file /Users/teamcity/buildAgent/work/e4f0eac9e33806e2/vendor/brightray/vendor/download/libchromiumcontent/static_library/libwebkit.a, file was built for archive which is not the architecture being linked (x86_64): /Users/teamcity/buildAgent/work/e4f0eac9e33806e2/vendor/brightray/vendor/download/libchromiumcontent/static_library/libwebkit.a
[02:56:38][Step 2/2]
Undefined symbols for architecture x86_64:
"blink::WebCryptoKeyAlgorithm::createRsaHashed(blink::WebCryptoAlgorithmId,
unsigned int, unsigned char const*, unsigned int, blink::WebCryptoAlgorithmId)",
referenced from:
webcrypto::(anonymous namespace)::CreateRsaHashedKeyAlgorithm(
blink::WebCryptoAlgorithmId, blink::WebCryptoAlgorithmId, evp_pkey_st*,
blink::WebCryptoKeyAlgorithm*) in libcomponents.a(rsa.o)
"blink::WebCryptoAlgorithm::rsaHashedImportParams() const", referenced from:
webcrypto::RsaHashedAlgorithm::ImportKeyPkcs8(webcrypto::CryptoData const&,
blink::WebCryptoAlgorithm const&, bool, int, blink::WebCryptoKey*) const
in libcomponents.a(rsa.o)
skipped log entries...
It looks like the library and build machine are not compatible, but both of them are x64 platforms. What else can be wrong? I put here only part of the log, because it's really very long (thousands of lines). I used to use the same steps for building 1.2.3, 1.2.8 and 1.4.3 versions and there was no problem.
Try setting the ur valid architectures in xcode..

compile 32bit dylib in 64bit osx

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?

Link dynamic library and ffmpeg x86_64 version

I'm working with FFMPEG on Mac OSX, my Mac version is 10.6.8 (i386).
When I try to compile my C++ code linking a dynamic library:
g++ sdk.cpp -rpath /usr/local/lib/libinsight.dylib -o sdk
I get the following error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
"av_open_input_file(AVFormatContext**, char const*, AVInputFormat*, int, AVFormatParameters*)", referenced from:
ffmpeg_open(AVFormatContext**, char const*, int*)in ccCkx9dd.o
(so forth fo every FFMPEG call)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Without linking dylib I have no problem. What's the matter?
P.S. ffmpeg version is Mach-O 64-bit executable x86_64
g++ sdk.cpp -rpath /usr/local/lib/libinsight.dylib -o sdk
Shouldn't you be linking to libffmpeg somewhere? Try adding -lffmpeg to your link command line.

Resources