简体   繁体   中英

Linking error during mex compilation

I wrote a c++ program which uses the library yaml-cpp. I built it myself using cmake and the library is now located as /usr/local/lib/libyaml-cpp.a . In my eclipse project, building the program works fine.

For testing the program output in matlab, I also embedded the program into a mex wrapper. I try to compile the following mex command:

prefix = '../../Synthesizer/src/'; 
mex ('-g', '../mex/synth_process_mex.cpp', [prefix 'test/TestClient.cpp'], [prefix 'Synth.cpp'], ...
    [prefix 'DataReader.cpp'], [prefix 'StochasticDataReader.cpp'], [prefix 'GlobalMath.cpp'],...
    [prefix 'Sinusoid.cpp'], [prefix 'Interpolator.cpp'], [prefix 'OSCReceiver.cpp'],...
    [prefix 'Voice.cpp'], '-lyaml-cpp');

This used to work fine, until I started using the yaml-cpp library. Now, Matlab returns the following error message:

Error using mex
/usr/bin/ld: //usr/local/lib/libyaml-cpp.a(parse.cpp.o): Die Umlagerung von
//usr/local/lib/libyaml-cpp.a: error adding symbols: Ungültiger Wert
collect2: error: ld returned 1 exit status

Can anybody help me with that? Sorry, I didn't know how to change the language of the compiler message.

It seems, that the problem was, that I used a statically library version of yaml-cpp. I changed to a shared library, libyaml-cpp.so and everthing works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM