C++ linker error combining c and cpp code: 'unsupported file format' -


i'm trying combine c , c++ code, when try link unexpected error:

ld: warning: ignoring file edmonds.o, file built unsupported file format ( 0x43 0x50 0x43 0x48 0x01 0x0c 0x00 0x00 0x64 0x08 0x00 0x00 0x0b 0x02 0x68 0x42 ) not architecture being linked (x86_64)

here's setup:

dummy.c

void edmonds(int n, double* weights, int* heads);  int main() {     int = 1;     edmonds(1234,0,&a);     return 0; } 

edmonds.hpp:

extern "c" void edmonds(int n, double* weights, int* heads);  void edmonds(int n, double* weights, int* heads) {     heads[0]=n*4;     return; } 

i compile manually using following sequence of commands:

clang -c dummy.c -o dummy.o clang++ -c edmonds.hpp -o edmonds.o clang++ edmonds.o dummy.o -o main.o 

with above mentioned result

ld: warning: ignoring file edmonds.o, file built unsupported file format ( 0x43 0x50 0x43 0x48 0x01 0x0c 0x00 0x00 0x64 0x08 0x00 0x00 0x0b 0x02 0x68 0x42 ) not architecture being linked (x86_64): edmonds.o undefined symbols architecture x86_64:   "_edmonds", referenced from:       _main in dummy.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

my system osx yosemite. don't understand why edmonds.hpp gets compiled weird file format not x86_64.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -