[MINC-users] Problem Compiling Minc

Simon Fristed Eskildsen se at hst.aau.dk
Tue Apr 22 05:40:50 EDT 2008


Hi Bilal,
Try putting the linker libraries at the end of the g++ statements and 
change the order so the dependency goes from left to right (that usually 
works with gcc):
g++ -o MincTest MincThreshold.o MincCorrectPV.o CheckDimensions.o 
MincTest.o -lvolume_io -lminc -lnetcdf

I have omitted the -Wl option above, as I'm not sure what you're trying 
to pass to the linker.
Also, in your makefile, LDFLAGS should point at the library paths, e.g. 
-L/usr/local/mni/lib, while LIBS should hold the dynamic libraries, e.g. 
-lvolume_io ...

And finally, newline at end of file ;)

Hope it helps,
Simon

Bilal Abdul Mujeeb wrote:
> Hi,
> I am using minc library 1.5 to develop some applications. I am working simple c++ classes using minc headers. 
> I am using them on OS X 10.5.2 with GCC 4.x.x for MAC, it works fine on my mac. But when i took the same code on a linux machine it gives me linking errors. The link libraries for minc in both mac and linux sytem are .a and .la.
> 
>  I have added the library path in make file as well but no use. I have tried using Extern "C" to declare function again in my code but in mac it dont give me any error but on linux its gives error of redecleration.
> 
> my compiler output is as follow: 
> ------------------------------------------------------------------
> bilal at BILAL:~/workspace/MincTest$ make
> g++ -O2 -g -Wall -fmessage-length=0 -Wno-deprecated   -c -o MincThreshold.o MincThreshold.cpp
> MincThreshold.cpp:172:2: warning: no newline at end of file
> MincThreshold.cpp: In member function ‘void MincThreshold::printVolumeInfo(volume_struct*, int*)’:
> MincThreshold.cpp:28: warning: unused variable ‘value’
> MincThreshold.cpp: In member function ‘int MincThreshold::saveVolume(volume_struct*, char*, char*)’:
> MincThreshold.cpp:168: warning: deprecated conversion from string constant to ‘char*’
> g++ -O2 -g -Wall -fmessage-length=0 -Wno-deprecated   -c -o MincCorrectPV.o MincCorrectPV.cpp
> MincCorrectPV.cpp: In member function ‘int MincCorrectPV::saveVolume(volume_struct*, char*, char*)’:
> MincCorrectPV.cpp:82: warning: deprecated conversion from string constant to ‘char*’
> g++ -O2 -g -Wall -fmessage-length=0 -Wno-deprecated   -c -o CheckDimensions.o CheckDimensions.cpp
> CheckDimensions.cpp:49:2: warning: no newline at end of file
> CheckDimensions.cpp: In member function ‘int CheckDimensions::saveVolume(volume_struct*, char*, char*)’:
> CheckDimensions.cpp:45: warning: deprecated conversion from string constant to ‘char*’
> g++ -O2 -g -Wall -fmessage-length=0 -Wno-deprecated   -c -o MincTest.o MincTest.cpp
> MincTest.cpp:33:2: warning: no newline at end of file
> g++ -lminc -lnetcdf -lvolume_io -Wl -o MincTest MincThreshold.o MincCorrectPV.o CheckDimensions.o MincTest.o
> MincThreshold.o: In function `MincThreshold::saveVolume(volume_struct*, char*, char*)':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:168: undefined reference to `output_modified_volume'
> MincThreshold.o: In function `MincThreshold::normalThreshold(volume_struct*, int*, double, int)':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:150: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:158: undefined reference to `set_volume_real_value'
> MincThreshold.o: In function `MincThreshold::bandThreshold(volume_struct*, int*, double, double, int)':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:128: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:136: undefined reference to `set_volume_real_value'
> MincThreshold.o: In function `~MincThreshold':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:12: undefined reference to `delete_volume'
> MincThreshold.o: In function `MincThreshold::printVolumeInfo(volume_struct*, int*)':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:36: undefined reference to `get_volume_nc_data_type'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:40: undefined reference to `get_volume_n_dimensions'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:45: undefined reference to `get_volume_voxel_max'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:46: undefined reference to `get_volume_voxel_min'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:50: undefined reference to `get_volume_real_max'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:51: undefined reference to `get_volume_real_min'
> MincThreshold.o: In function `MincThreshold::parseArguments(int, char**)':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:97: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:98: undefined reference to `get_volume_sizes'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:106: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:107: undefined reference to `get_volume_sizes'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:85: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:86: undefined reference to `get_volume_sizes'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:75: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:76: undefined reference to `get_volume_sizes'
> MincThreshold.o: In function `~MincThreshold':
> /home/bilal/workspace/MincTest/MincThreshold.cpp:12: undefined reference to `delete_volume'
> /home/bilal/workspace/MincTest/MincThreshold.cpp:12: undefined reference to `delete_volume'
> MincCorrectPV.o: In function `MincCorrectPV::correctPV_Morphology(volume_struct*, int*, volume_struct*, int*, int, double, volume_struct*, volume_struct*)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:114: undefined reference to `copy_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:122: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:123: undefined reference to `set_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:128: undefined reference to `set_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:129: undefined reference to `set_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:143: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:149: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:150: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:164: undefined reference to `get_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:166: undefined reference to `get_volume_real_value'
> MincCorrectPV.o:/home/bilal/workspace/MincTest/MincCorrectPV.cpp:164: more undefined references to `get_volume_real_value' follow
> MincCorrectPV.o: In function `MincCorrectPV::correctPV_Morphology(volume_struct*, int*, volume_struct*, int*, int, double, volume_struct*, volume_struct*)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:173: undefined reference to `set_volume_real_value'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:167: undefined reference to `set_volume_real_value'
> MincCorrectPV.o: In function `MincCorrectPV::saveVolume(volume_struct*, char*, char*)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:82: undefined reference to `output_modified_volume'
> MincCorrectPV.o: In function `MincCorrectPV::correct_GM_PV(char*, char*)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:91: undefined reference to `copy_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:92: undefined reference to `copy_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:106: undefined reference to `delete_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:107: undefined reference to `delete_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:108: undefined reference to `delete_volume'
> MincCorrectPV.o: In function `MincCorrectPV::checkMincRange(volume_struct*, double, double)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:75: undefined reference to `get_volume_real_min'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:75: undefined reference to `get_volume_real_max'
> MincCorrectPV.o: In function `MincCorrectPV::praseParameters(int, char**)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:40: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:40: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:42: undefined reference to `get_volume_sizes'
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:43: undefined reference to `get_volume_sizes'
> MincCorrectPV.o: In function `MincCorrectPV::correctPV_Morphology(volume_struct*, int*, volume_struct*, int*, int, double, volume_struct*, volume_struct*)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:182: undefined reference to `delete_volume'
> MincCorrectPV.o: In function `MincCorrectPV::correct_GM_PV(char*, char*)':
> /home/bilal/workspace/MincTest/MincCorrectPV.cpp:109: undefined reference to `delete_volume'
> CheckDimensions.o: In function `CheckDimensions::saveVolume(volume_struct*, char*, char*)':
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:45: undefined reference to `output_modified_volume'
> CheckDimensions.o: In function `CheckDimensions::viewDimensions(volume_struct*, int*)':
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:31: undefined reference to `get_volume_voxel_max'
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:35: undefined reference to `set_volume_real_value'
> CheckDimensions.o: In function `CheckDimensions::parseArguments(int, char**)':
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:18: undefined reference to `input_volume'
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:19: undefined reference to `get_volume_sizes'
> CheckDimensions.o: In function `~CheckDimensions':
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:12: undefined reference to `delete_volume'
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:12: undefined reference to `delete_volume'
> /home/bilal/workspace/MincTest/CheckDimensions.cpp:12: undefined reference to `delete_volume'
> collect2: ld returned 1 exit status
> make: *** [MincTest] Error 1
> --------------------------------------------------------------------------------------
> 
> my make file......
> 
> LDFLAGS = -lminc -lnetcdf -lvolume_io -Wl
> 
> CXXFLAGS =    -O2 -g -Wall -fmessage-length=0 -Wno-deprecated
> 
> OBJS =        MincThreshold.o MincCorrectPV.o CheckDimensions.o MincTest.o    
> 
> LIBS =
> 
> TARGET =    MincTest
> 
> $(TARGET):    $(OBJS)
>     $(CXX) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
> 
> all:    $(TARGET)
> 
> clean:
>     rm -f $(OBJS) $(TARGET)
> 
> 
> 
> Regards,
> Bilal
> 
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www2.bic.mni.mcgill.ca/mailman/listinfo/minc-users


More information about the MINC-users mailing list