I have a linker problem under linux. This is my cmake file:
cmake_minimum_required(VERSION 2.6)
# Locate GTest
find_package(GTest REQUIRED Boost)
include_directories(${GTEST_INCLUDE_DIRS})
file(GLOB info_model
"../src/info_model/*.h"
"../src/info_model/*.cpp"
"../src/gcc_xml_parsing/*.h"
"../src/gcc_xml_parsing/*.cpp"
"../src/messages_filed_with_values/*.h"
"../src/messages_filed_with_values/*.cpp"
)
# Link runTests with what we want to test and the GTest and pthread library
add_library(info_model_lib STATIC ${info_model} )
add_executable(runTests_xml unit/gcc_xml_parsing/ut_XMLFile.cpp )
add_executable(runTests_hexDumpUtil unit/info_model/ut_HexDumpUtil.cpp )
add_executable(runTests_cstruct unit/info_model/ut_CStruct.cpp )
add_executable(runTests_primitive_type_field unit/info_model/ut_PrimitiveTypeField.cpp )
add_executable(runTests_enumField unit/info_model/ut_EnumField.cpp )
add_executable(runTests_ArrayOfFields unit/info_model/ut_ArrayType.cpp )
target_link_libraries(runTests_xml ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib)
target_link_libraries(runTests_hexDumpUtil ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib)
target_link_libraries(runTests_cstruct ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib)
target_link_libraries(runTests_primitive_type_field ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib)
target_link_libraries(runTests_enumField ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib)
target_link_libraries(runTests_ArrayOfFields ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib)
However, the linker throwns an error, which start (I didn't provide the whole log, because it is 5 times larger than the below):
libinfo_model_lib.a(XMLFile.cpp.o): In function `bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>)':
Thank you for helping
You have to link yours library before boost::regex
target_link_libraries(runTests_xml ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} info_model_lib pthread boost_regex boost_thread )
Related
Project Structure
ffmpeg-tutorial
include
libavcodec
libavdevice
libavfilter
libavformat
libavutil
libswresample
libswscale
lib
pkgconfig
libavcodec.a
libavdevice.a
libavfilter.a
libformat.a
libavutil.a
libswresample.a
libswscale.a
CMakeLists.txt
main.c
CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(ffmpeg_tutorial)
set(CMAKE_C_STANDARD 11)
include_directories(include)
link_directories(lib)
add_executable(ffmpeg_tutorial main.cpp)
target_link_libraries(ffmpeg_tutorial
avformat
avcodec
avutil
swscale
swresample
z
bz2
iconv
ws2_32
schannel
kernel32
advapi32
kernel32
user32
gdi32
winspool
shell32
ole32
oleaut32
uuid
comdlg32
advapi32
)
main.c
#include <stdio.h>
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswresample/swresample.h"
int main() {
std::cout << "Hello, World!" << std::endl;
std::cout << av_version_info() << std::endl;
printf("ffmpeg version is %s\n", av_version_info());
// Open input file
AVFormatContext *inputContext = nullptr;
if (avformat_open_input(&inputContext, "input.mp3", nullptr, nullptr) != 0) {
printf("Couldn't open input file\n");
return -1;
}
// Read input stream
if (avformat_find_stream_info(inputContext, nullptr) < 0) {
printf("Couldn't find stream information\n");
return -1;
}
// Get audio stream index
int audioStream = -1;
for (int i = 0; i < inputContext->nb_streams; i++) {
if (inputContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
audioStream = i;
break;
}
}
if (audioStream == -1) {
printf("Couldn't find audio stream\n");
return -1;
}
}
IDE
clion
ERRORS
[ 50%] Building CXX object CMakeFiles/ffmpeg_tutorial.dir/main.cpp.obj
[100%] Linking CXX executable ffmpeg_tutorial.exe
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: G:/cywen_private/cpp_projects/ffmpeg-tutorial/lib/libavformat.a(tls_schannel.o): in function `tls_write':
D:\Msys64\usr\src\ffmpeg/libavformat/tls_schannel.c:563: undefined reference to `EncryptMessage'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: G:/cywen_private/cpp_projects/ffmpeg-tutorial/lib/libavformat.a(tls_schannel.o): in function `tls_read':
D:\Msys64\usr\src\ffmpeg/libavformat/tls_schannel.c:441: undefined reference to `DecryptMessage'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: G:/cywen_private/cpp_projects/ffmpeg-tutorial/lib/libavcodec.a(mfenc.o):mfenc.c:(.rdata$.refptr.IID_ICodecAPI[.refptr.IID_ICodecAPI]+0x0): undefined reference to `IID_ICodecAPI'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: G:/cywen_private/cpp_projects/ffmpeg-tutorial/lib/libavcodec.a(tiff.o): in function `tiff_uncompress_lzma':
D:\Msys64\usr\src\ffmpeg/libavcodec/tiff.c:577: undefined reference to `lzma_stream_decoder'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\Msys64\usr\src\ffmpeg/libavcodec/tiff.c:582: undefined reference to `lzma_code'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\Msys64\usr\src\ffmpeg/libavcodec/tiff.c:583: undefined reference to `lzma_end'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: G:/cywen_private/cpp_projects/ffmpeg-tutorial/lib/libavutil.a(random_seed.o): in function `av_get_random_seed':
D:\Msys64\usr\src\ffmpeg/libavutil/random_seed.c:127: undefined reference to `BCryptOpenAlgorithmProvider'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\Msys64\usr\src\ffmpeg/libavutil/random_seed.c:130: undefined reference to `BCryptGenRandom'
D:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\Msys64\usr\src\ffmpeg/libavutil/random_seed.c:131: undefined reference to `BCryptCloseAlgorithmProvider'
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [CMakeFiles\ffmpeg_tutorial.dir\build.make:95: ffmpeg_tutorial.exe] Error 1
mingw32-make[2]: *** [CMakeFiles\Makefile2:82: CMakeFiles/ffmpeg_tutorial.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:89: CMakeFiles/ffmpeg_tutorial.dir/rule] Error 2
mingw32-make: *** [Makefile:123: ffmpeg_tutorial] Error 2
What is the way I compile ffmpeg
downlaod msys2
install mingw64
pacman -S mingw-w64-x86_64-toolchain
install make,diffutils,nasm,yasm,pkg-config
pacman -S base-devl yasm nasm pkg-config
download ffmpeg 5.1
compile
cd ffmpeg
./configure --disable-shared --enable-static --arch=x86_64 --target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --pkg-config-flags=--static --prefix=../ffmpeg-build
make -j $(nproc)
make install
Project Repoistory
https://github.com/joinwen/learn_ffmpeg.git
Expectation
How to solve errors
In CMakeLists target_link_libraries's parameters is too much, Can I make it short
some advices on the project
I tried to build WebKit GTK on my ARM Mac, but the linking process fails:
Undefined symbols for architecture arm64:
"_u_charDirection_67", referenced from:
WTF::StringImpl::stripWhiteSpace() in libWTFGTK.a(StringImpl.cpp.o)
WTF::StringImpl::simplifyWhiteSpace() in libWTFGTK.a(StringImpl.cpp.o)
WTF::StringImpl::defaultWritingDirection(bool*) in libWTFGTK.a(StringImpl.cpp.o)
int WTF::toIntegralType<int, char16_t>(char16_t const*, unsigned long, bool*, int) in libWTFGTK.a(WTFString.cpp.o)
unsigned int WTF::toIntegralType<unsigned int, char16_t>(char16_t const*, unsigned long, bool*, int) in libWTFGTK.a(WTFString.cpp.o)
long long WTF::toIntegralType<long long, char16_t>(char16_t const*, unsigned long, bool*, int) in libWTFGTK.a(WTFString.cpp.o)
unsigned long long WTF::toIntegralType<unsigned long long, char16_t>(char16_t const*, unsigned long, bool*, int) in libWTFGTK.a(WTFString.cpp.o)
...
"_u_foldCase_67", referenced from:
WTF::StringImpl::foldCase() in libWTFGTK.a(StringImpl.cpp.o)
"_u_strFoldCase_67", referenced from:
WTF::StringImpl::foldCase() in libWTFGTK.a(StringImpl.cpp.o)
"_u_strToLower_67", referenced from:
WTF::StringImpl::convertToLowercaseWithoutLocale() in libWTFGTK.a(StringImpl.cpp.o)
WTF::StringImpl::convertToLowercaseWithLocale(WTF::AtomString const&) in libWTFGTK.a(StringImpl.cpp.o)
"_u_strToUpper_67", referenced from:
WTF::StringImpl::convertToUppercaseWithoutLocale() in libWTFGTK.a(StringImpl.cpp.o)
...
WTF::normalizedNFC(WTF::StringView) in libWTFGTK.a(StringView.cpp.o)
"_unorm2_isNormalized_67", referenced from:
WTF::normalizedNFC(WTF::StringView) in libWTFGTK.a(StringView.cpp.o)
"_unorm2_normalize_67", referenced from:
WTF::normalizedNFC(WTF::StringView) in libWTFGTK.a(StringView.cpp.o)
"_utext_close_67", referenced from:
WTF::setTextForIterator(UBreakIterator&, WTF::StringView) in libWTFGTK.a(TextBreakIterator.cpp.o)
WTF::acquireLineBreakIterator(WTF::StringView, WTF::AtomString const&, char16_t const*, unsigned int, WTF::LineBreakIteratorMode) in libWTFGTK.a(TextBreakIterator.cpp.o)
WTF::TextBreakIteratorICU::TextBreakIteratorICU(WTF::StringView, WTF::TextBreakIteratorICU::Mode, char const*) in libWTFGTK.a(TextBreakIterator.cpp.o)
"_utext_setup_67", referenced from:
WTF::openLatin1UTextProvider(WTF::UTextWithBuffer*, unsigned char const*, unsigned int, UErrorCode*) in libWTFGTK.a(UTextProviderLatin1.cpp.o)
WTF::openLatin1ContextAwareUTextProvider(WTF::UTextWithBuffer*, unsigned char const*, unsigned int, char16_t const*, int, UErrorCode*) in libWTFGTK.a(UTextProviderLatin1.cpp.o)
WTF::uTextLatin1Clone(UText*, UText const*, signed char, UErrorCode*) in libWTFGTK.a(UTextProviderLatin1.cpp.o)
WTF::openUTF16ContextAwareUTextProvider(UText*, char16_t const*, unsigned int, char16_t const*, int, UErrorCode*) in libWTFGTK.a(UTextProviderUTF16.cpp.o)
WTF::uTextCloneImpl(UText*, UText const*, signed char, UErrorCode*) in libWTFGTK.a(UTextProvider.cpp.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/WebKitWebDriver] Error 1
I'm not sure why this is happening. It compiled just fine on my Intel Mac. Any ideas on how to fix this?
I am trying to convert the given C code to DLL file I tried to compile the given code but it doesn't work it gives me an error
.\sample.cpp:16:66: warning: passing NULL to non-pointer argument 5 of 'void* CreateThread(LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, PVOID, DWORD, PDWORD)' [-Wconversion-null]
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../libmingw32.a(main.o):(.text.startup+0xb0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
I have already tried looking up the answers available online, along with looking at the syntax which seems to be okay.
My Code
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
extern "C" __declspec(dllexport)
DWORD WINAPI MessageBoxThread(LPVOID lpParam) {
MessageBox(NULL, "Hello world!", "Hello World!", NULL);
return 0;
}
extern "C" __declspec(dllexport)
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
CreateThread(NULL, NULL, MessageBoxThread, NULL, NULL, NULL);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
I'm using Visual Studio 2017 community edition, version 15.8.1 for reference. I created a simple DLL project (using File | New | Project) and removed all files except dllmain.cpp I had to modify the project properties to disable the use of precompiled headers. The code in dllmain.cpp is:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
extern "C" __declspec(dllexport)
DWORD WINAPI MessageBoxThread(LPVOID lpParam)
{
MessageBoxA(NULL, "Hello World", "Hello World", MB_YESNO);
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DWORD dwTID;
CreateThread(nullptr, 0, MessageBoxThread, nullptr, 0, &dwTID);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
I've made a few modifications from your code,
I passed MB_YESNO as the final argument to MessageBox instead of a null pointer. This will give your message box YES and NO buttons, and this matches the type expected (uint) for the fourth parameter.
I used MessageBoxA to force ASCII argument instead of MessageBox, which is a typedef that resolves to MessageBoxW. This effects the type of strings that is expected, and is based on if you are using Unicode or not.
I passed a value of zero for the second argument (dwStackSize) and the fifth argument (dwCreationFlags) of CreateThread instead of NULL. Both of these arguments have type DWORD. Notice that this fixes the first line of your error message ".\sample.cpp:16:66: warning: passing NULL to non-pointer argument 5"
I declared a variable dwTID and pass a pointer to it as the sixth argument of CreateThread.
I added a break statement to the first case. This should not have any consequence in the code. I just think it is a good idea.
The above code compiles without warnings or errors. Thus I believe that your code should also compile as well. Thus I strongly suspect that the errors you are seeing are due to the compiler and linker flags you are using. The command lines that are being used are
for compilation:
/JMC /permissive- /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm- /Od /sdl /Fd"Debug\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "TESTDLL_EXPORTS" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /FC /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\testDll.pch" /diagnostics:classic
for linking:
/OUT:"D:\GNUHome\Projects\testDll\Debug\testDll.dll" /MANIFEST /NXCOMPAT /PDB:"D:\GNUHome\Projects\testDll\Debug\testDll.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib"/IMPLIB:"D:\GNUHome\Projects\testDll\Debug\testDll.lib" /DEBUG /DLL /MACHINE:X86 /INCREMENTAL /PGD:"D:\GNUHome\Projects\testDll\Debug\testDll.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\testDll.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
Because you are not using native Microsoft toos (CL and LINK), you are going to need to find or prepare a mapping between the tool chain you are using (which you did not mention, but it appears to be mingw from the error messages) and Microsoft's tool chain.
If'n I had to guess, I would suspect that the issue is due to the /DLL flag in the linking command line. You might have to use something line -shared with mingw. However this is just a guess.
I met the following error while compiling z3. It seems to be an error for ld. I wonder what I can do to make it compile. It is a problem from the opt branch in git. I am on iMac with OS X 10.9.2 (13C1021)
I am with xcode Version 5.1.1 (5B1008) with xcode-select tools installed to version 2333. I use port with version 2.2.1 with ld installed.
The problem seems to be a linking problem. I am using link loader as: ld64 #136_2+llvm33 (active)
My gcc is gcc (MacPorts gcc48 4.8.2_0) 4.8.2
Thank you very much!
g++ -o z3 shell/datalog_frontend.o shell/dimacs_frontend.o
shell/gparams_register_modules.o shell/install_tactic.o shell/main.o
shell/mem_initializer.o shell/smtlib_frontend.o shell/z3_log_frontend.o api/api.a opt/opt.a parsers/smt/smtparser.a tactic/portfolio/portfolio.a tactic/ufbv/ufbv_tactic.a tactic/smtlogics/smtlogic_tactics.a muz/fp/fp.a muz/duality/duality_intf.a muz/bmc/bmc.a muz/tab/tab.a muz/clp/clp.a muz/pdr/pdr.a muz/rel/rel.a muz/transforms/transforms.a muz/base/muz.a duality/duality.a qe/qe.a tactic/sls/sls_tactic.a smt/tactic/smt_tactic.a tactic/fpa/fpa.a tactic/bv/bv_tactics.a smt/user_plugin/user_plugin.a smt/smt.a smt/proto_model/proto_model.a smt/params/smt_params.a ast/rewriter/bit_blaster/bit_blaster.a ast/pattern/pattern.a ast/macros/macros.a ast/simplifier/simplifier.a ast/proof_checker/proof_checker.a parsers/smt2/smt2parser.a cmd_context/extra_cmds/extra_cmds.a cmd_context/cmd_context.a interp/interp.a solver/solver.a tactic/aig/aig_tactic.a math/subpaving/tactic/subpaving_tactic.a nlsat/tactic/nlsat_tactic.a tactic/arith/arith_tactics.a sat/tactic/sat_tactic.a tactic/core/core_tactics.a math/euclid/euclid.a math/grobner/grobner.a parsers/util/parser_util.a ast/substitution/substitution.a tactic/tactic.a model/model.a ast/normal_forms/normal_forms.a ast/rewriter/rewriter.a ast/ast.a math/subpaving/subpaving.a math/realclosure/realclosure.a math/interval/interval.a math/simplex/simplex.a math/hilbert/hilbert.a nlsat/nlsat.a sat/sat.a math/polynomial/polynomial.a util/util.a -lpthread -fopenmp
0 0x1079c1a68 __assert_rtn + 144
1 0x107a3bccd mach_o::relocatable::Parser<x86_64>::parse(mach_o::relocatable::ParserOptions const&) + 1039
2 0x107a2b899 mach_o::relocatable::Parser<x86_64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 313
3 0x107a290f0 mach_o::relocatable::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 208
4 0x107a18797 archive::File<x86_64>::makeObjectFileForMember(archive::File<x86_64>::Entry const*) const + 795
5 0x107a182b3 archive::File<x86_64>::justInTimeforEachAtom(char const*, ld::File::AtomHandler&) const + 139
6 0x1079c5d46 ld::tool::InputFiles::searchLibraries(char const*, bool, bool, bool, ld::File::AtomHandler&) const + 210
7 0x107a0b772 ld::tool::Resolver::resolveUndefines() + 200
8 0x107a0d6e1 ld::tool::Resolver::resolve() + 75
9 0x1079c1d44 main + 370
A linker snapshot was created at:
/tmp/z3-2014-03-25-110931.ld-snapshot
ld: Assertion failed: (cfiStartsArray[i] != cfiStartsArray[i-1]), function parse, file src/ld/parsers/macho_relocatable_file.cpp, line 1555.
collect2: error: ld returned 1 exit status
make: *** [z3] Error 1
It is because we used port and installed gcc and ld and other packages.
Another possibility is that ld was depend on llvm 3.3 rather than llvm 3.4. The problem was solved after updating ld.
When I try to compile example1.cpp that comes with Armadillo 2.4.2, I keep getting the following linking error:
/tmp/ccbnLbA0.o: In function `double arma::blas::dot<double>(unsigned int, double const*, double const*)':
main.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[double arma::blas::dot<double>(unsigned int, double const*, double const*)]+0x3b): undefined reference to `wrapper_ddot_'
/tmp/ccbnLbA0.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
main.cpp:(.text._ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_[void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)]+0x68): undefined reference to `wrapper_dgemv_'
/tmp/ccbnLbA0.o: In function `void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
main.cpp:(.text._ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_[void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)]+0x7a): undefined reference to `wrapper_dgemm_'
collect2: ld returned 1 exit status
Can someone help? I manually installed
latest version of BLAS
lapack-3.4.0
boost-1.48.0
latest version of ATLAS
I'm using Ubuntu 11.04 on the MacBook Pro 7,1 model
Thank you so much to osgx! After reading his comment, I took a second look at the README file! It turns out I was missing '-O1 -larmadillo' in the command!
Here's the command I used to get it working:
g++ example1.cpp -o example1 -O1 -larmadillo
Stupid mistake, I know.... It just goes to remind you how important it is to read the README.
The README also mentions:
If you get linking errors, or if Armadillo was installed manually
and you specified that LAPACK and BLAS are available, you will
need to explicitly link with LAPACK and BLAS (or their equivalents),
for example:
g++ example1.cpp -o example1 -O1 -llapack -lblas
I didn't have to include '-llapack -lblas' but maybe this will help anyone else who's having similar problems.
As of 5.0.0 (might also apply to earlier versions)
You actually need -larmadillo, on Fedora 21 -llapack and -lopenblas are not excplicitly necessary anymore.
There's an oddity I just discovered by comparing previously working compilations of code with the very problem of this thread, stressing the involvement of the gnu cc (I'm no expert in this): on my machine compilation success depends on the order of parameters to the gcc/g++ where
g++ infile -o outfile -libarmadillo ... worked, but
g++ -libarmadillo infile -o outfile ... didnt with (almost) the same error as mentioned above.
(hope that helps).