![]() |
| | #1 |
| Registered User Join Date: Jun 2008
Posts: 106
| linker errors: Code: g++ -Wall -O -g img-validate.cpp -I/prog/lib/hdf5-1.8.1/hdf5/include/ -L /prog/lib/hdf5-1.8.1/hdf5/lib -lhdf5_cpp -lhdf5_hl -lhdf5 -lz -lstdc++ -lm -ltiff -o run Code: /tmp/ccPVQaqt.o: In function `dataset_loader::compute_blob_metric_stats(dataset_buf const&, int, dataset_buf const&, dataset_buf const&, dataset_buf const&, dataset_buf const&, dataset_buf&, dataset_buf&, dataset_buf&)': /prog/ana/src/h5/input.h:496: undefined reference to `dataset_loader::radon_thresh' /prog/ana/src/h5/input.h:497: undefined reference to `dataset_loader::sigma' /prog/ana/src/h5/input.h:501: undefined reference to `dataset_loader::radon_thresh' /prog/ana/src/h5/input.h:502: undefined reference to `dataset_loader::sigma' /tmp/ccPVQaqt.o: In function `dataset_loader::compute_sobel_edge_blob_metric_stats(dataset_buf const&, int, bool const*, dataset_buf const&, dataset_buf const&, dataset_buf const&, dataset_buf const&, dataset_buf&, dataset_buf&, dataset_buf&)': /prog/ana/src/h5/input.h:457: undefined reference to `dataset_loader::sigma' /prog/ana/src/h5/input.h:458: undefined reference to `dataset_loader::sigma' /tmp/ccPVQaqt.o: In function `dataset_loader::derive_sobel_edge_blob_summary()': /prog/ana/src/h5/input.h:393: undefined reference to `dataset_loader::sigma' /prog/ana/src/h5/input.h:396: undefined reference to `dataset_loader::sigma' /tmp/ccPVQaqt.o: In function `dataset_loader::derive_radon_blob_summary(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /prog/ana/src/h5/input.h:317: undefined reference to `dataset_loader::radon_thresh' /prog/ana/src/h5/input.h:320: undefined reference to `dataset_loader::radon_thresh' /prog/ana/src/h5/input.h:329: undefined reference to `dataset_loader::sigma' /prog/ana/src/h5/input.h:332: undefined reference to `dataset_loader::sigma' collect2: ld returned 1 exit status make: *** [all] Error 1 My img-validate code includes input.h which includes the HDF5 lib stuff. radom_thresh and sigma are just arrays of numbers from inside my code: from input.cpp: Code:
const float dataset_loader::sigma[] = {0, 0.5, 1, 2, 4, 6, 8, 12, 16, 20, 24, 28}; // Extra element added to end.
const float dataset_loader::radon_thresh[] = {2, 2.828427e+00, 4, 5.656854e+00, 8, 1.131371e+01, 16, 2.262742e+01, 32, 4.525483e+01, 64, 9.050967e+01, 128, 1.810193e+02, 256, 3.620387e+02, 512, 7.240773e+02, 1024, 1.448155e+03, 2048, 2.896309e+03, 4096, 4096*M_SQRT2}; // ditto.
Last edited by elninio; 07-27-2008 at 11:22 AM. |
| elninio is offline | |
| | #2 |
| Registered User Join Date: Jun 2008
Posts: 106
| these are the libs in /prog/lib/hdf5-1.8.1/hdf5/lib Code: libhdf5.a libhdf5.so.5@ libhdf5_hl.a libhdf5_hl.so.0.0.0* libhdf5.la* libhdf5.so.5.0.1* libhdf5_hl.la* libhdf5.settings libhdf5_cpp.a* libhdf5_hl.so@ libhdf5.so@ libhdf5_cpp.la* libhdf5_hl.so.0@ Code: H5ACpublic.h H5Dpublic.h H5FcreatProp.h* H5Ppublic.h H5AbstractDs.h* H5DxferProp.h* H5File.h* H5PredType.h* H5Apublic.h H5EnumType.h* H5FloatType.h* H5PropList.h* H5ArrayType.h* H5Epubgen.h H5Fpublic.h H5Rpublic.h H5AtomType.h* H5Epublic.h H5Gpublic.h H5Spublic.h H5Attribute.h* H5Exception.h* H5Group.h* H5StrType.h* H5Classes.h* H5FDcore.h H5IMpublic.h H5TBpublic.h H5CommonFG.h* H5FDdirect.h H5IdComponent.h* H5Tpublic.h H5CompType.h* H5FDfamily.h H5Include.h* H5VarLenType.h* H5Cpp.h* H5FDlog.h H5IntType.h* H5Zpublic.h H5Cpp.h.gch* H5FDmpi.h H5Ipublic.h H5api_adpt.h H5CppDoc.h* H5FDmpio.h H5LTpublic.h H5pubconf.h H5Cpublic.h H5FDmpiposix.h H5Library.h* H5public.h H5DSpublic.h H5FDmulti.h H5Lpublic.h H5version.h H5DataSet.h* H5FDpublic.h H5MMpublic.h hdf5.h H5DataSpace.h* H5FDsec2.h H5Object.h* hdf5_hl.h H5DataType.h* H5FDstdio.h H5Opublic.h H5DcreatProp.h* H5FaccProp.h* H5PTpublic.h |
| elninio is offline | |
| | #3 |
| Dr Dipshi++ Join Date: Oct 2006 Location: On me hyperplane
Posts: 1,219
| I'm not sure if this would do anything to fix your problem, but have you tried compiling you program first, then linking it afterwards. Perhaps using a makefile? I had a similar sort of problem that seemed to work after I separated the compiling and linking procedures. |
| mike_g is offline | |
| | #4 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| > -lhdf5_cpp -lhdf5_hl -lhdf5 Historically at least, order mattered. A symbol which would be resolved by library a, but not apparent until library b was linked would appear to be unresolved. But I thought the Linux version of ld took care of that problem. |
| Salem is offline | |
| | #5 |
| Registered User Join Date: Jun 2008
Posts: 106
| I don't understand how this works, could you explain it to me or link to me a doc? Do you suggest that I change the order of the libs? |
| elninio is offline | |
| | #6 | |
| Registered User Join Date: Jun 2008
Posts: 106
| Quote:
Code: all:
g++ the command listed above
| |
| elninio is offline | |
| | #7 |
| Dr Dipshi++ Join Date: Oct 2006 Location: On me hyperplane
Posts: 1,219
| Be warned: This is the first makefile I have made in my life, so I dont really know what I am doing here, but, this is what mine looks like: Code: COMPILER = gcc
CCFLAGS = -Wall -O2 -std=c99
all:
clear
${COMPILER} -c main.c ${CCFLAGS}
${COMPILER} -c shapes.c ${CCFLAGS}
${COMPILER} -c vector.c ${CCFLAGS}
${COMPILER} -c screen.c ${CCFLAGS}
${COMPILER} main.o shapes.o vector.o screen.o -lSDL -lm
./a.out
clean:
rm -rf *.o *.dat
|
| mike_g is offline | |
| | #8 |
| Registered User Join Date: Oct 2001
Posts: 2,110
| mike_g, the point of having a makefile is so that you can do only partial compilation of your program, whatever was changed since last time. To do that, you'll have to have separate rules for each of your source files. |
| robwhit is offline | |
| | #9 |
| Dr Dipshi++ Join Date: Oct 2006 Location: On me hyperplane
Posts: 1,219
| Oh, why would I have to have separate rules? Edit: there were following sections I hadent added in the post that just compile one source file and link it to the project. Is there a better way to do it? Last edited by mike_g; 07-27-2008 at 02:45 PM. |
| mike_g is offline | |
| | #10 |
| Registered User Join Date: Oct 2001
Posts: 2,110
| Code: COMPILER = gcc
CCFLAGS = -Wall -O2 -std=c99
.PHONY: clean # without this, if there was a file named clean, the clean target would be considered up to date.
all: myprogram
myprogram: main.o shapes.o vector.o screen.o
${COMPILER} main.o shapes.o vector.o screen.o -lSDL -lm -o myprogram
main.o: main.c main.h
${COMPILER} -c main.c ${CCFLAGS}
shapes.o: shapes.c shapes.h
${COMPILER} -c shapes.c ${CCFLAGS}
vector.o: vector.c vector.h
${COMPILER} -c vector.c ${CCFLAGS}
screen.o: screen.c screen.h
${COMPILER} -c screen.c ${CCFLAGS}
clean:
rm -rf *.o *.dat
Last edited by robwhit; 07-27-2008 at 03:15 PM. |
| robwhit is offline | |
| | #11 |
| Dr Dipshi++ Join Date: Oct 2006 Location: On me hyperplane
Posts: 1,219
| Oh I get it now. Cheers. |
| mike_g is offline | |
| | #12 |
| Registered User Join Date: Jun 2008
Posts: 106
| Fixed it. The file that contained the radon declaration was not in the compiling command. input.cpp. input.cpp includes input.h, but input.h does not include input.cpp. |
| elninio is offline | |
| | #13 |
| Registered User Join Date: Oct 2001
Posts: 2,110
| Header files shouldn't be in the compile line, only in the dependency list. |
| robwhit is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linker errors | jw232 | C++ Programming | 3 | 06-12-2009 12:56 PM |
| Linker errors in VC++ 2005 | C+/- | C++ Programming | 0 | 05-18-2007 07:42 AM |
| Sneaky little linker errors... | Tozar | C++ Programming | 8 | 10-25-2006 05:40 AM |
| Linker errors with Visual C++ | codegirl | C++ Programming | 4 | 09-11-2003 09:20 AM |
| MSVis-Studio C++ libraries and linker errors | kellydj | Windows Programming | 10 | 03-12-2002 02:03 PM |