C++ Compilation Issue with SimpleXlsx
C++ library for creating XLSX files for MS Excel 2007 and above.
Brought to you by:
oxod,
programmeralex
I have a cpp project built out of Code::Blocks that was written by another coder. I am trying to compile the project and am getting hung up with a "Undefined reference to SimpleXlsx" error. See snippet of the build log below. I would greatly appreciate any input on this. I have tried everything that I know to resolve this. Thanks in advance.
obj\Debug\pc\c3\C3Main.o: In function
ZN7C3Frame18OnSummaryBookReadyER14wxCommandEvent': C:/pc/c3/C3Main.cpp:4402: undefined reference toSimpleXlsx::CWorkbook::Save(std::__cxx11::basic_string<wchar_t, std::char_traits\<wchar_t="">, std::allocator\<wchar_t> > const&)'obj\Debug\pc\c3\table_gen_thread.o: In function
ZN15TTableGenThread21PopulateBookFromFilesEv': C:/pc/c3/table_gen_thread.cpp:155: undefined reference toSimpleXlsx::CWorkbook::AddSheet(std::__cxx11::basic_string<wchar_t, std::char_traits\<wchar_t="">, std::allocator\<wchar_t> > const&, std::vector<simplexlsx::columnwidth, std::allocator\<simplexlsx::columnwidth=""> >&)'C:/pc/c3/table_gen_thread.cpp:264: undefined reference to `SimpleXlsx::CWorkbook::AddSheet(std::__cxx11::basic_string<wchar_t, std::char_traits\<wchar_t="">, std::allocator\<wchar_t> > const&, std::vector<simplexlsx::columnwidth, std::allocator\<simplexlsx::columnwidth=""> >&)'</simplexlsx::columnwidth,></wchar_t></wchar_t,></simplexlsx::columnwidth,></wchar_t></wchar_t,></wchar_t></wchar_t,>
Hi,
Most likely SimpleXlsx was compiled separately and at the linking stage a ready obj file was specified. You can separately compile SimpleXlsx using CMake and specify an obj file to the linker.
Or try adding all *.h, *.c, *.hpp, *.cpp files (preserving the directory structure) from the SimpleXlsx project to your project and rebuild your project.
If it does not help, please specify version of the compiler and SimpleXlsx (macro SIMPLE_XLSX_VERSION in SimpleXlsxDef.h).
Hi,
you should unpack project from this file into folder "Source" of the SimpleXlsx-r028 package. Then you can build a static lib with C::B and link it to your project.
Hi,
I did create the static lib of r0.28 without any problems using cmake and VC++ 2017.
But I have problems to add it to my VC++ (mfc) project: What is the correct include file to be included into the project using the static SimpleXlsx.lib?
If I include Workbook.h the .cpp files of SimpleXlsx are compiled too.... ?
Thanks!
OK now,
could figure out what was going wrong. Did upgrade from r.20 to r.28 and there were some cpp's left in my project.
Static SimpleXlsx.lib and VC++ 2017 is working fine - thank you very much!
Thanks for your help Alexandr and E.Naumovich. I am trying your suggestions now and I will let you know the outcome. I really appreciate your input.
I am still not having success in compiling my project. The project was written using Code::Blocks 13.12; wxWidgets 2.9.4; SimpleXlsx 0.20 and compiled using MngGW-gcc 4.7.2. I am currently using Code::Blocks 17.12 and compiling with MingGW-gcc 5.1.0. The project has the SimpleXlsx files within the file structure. I am using the files for SimpleXlsx and wxWidgets from the file structure contained within the project. The project is compiling fine until it gets to the undefined reference to SimpleXlsx.
Again, I would greatly appreciate your thoughts on this. I have done some coding in the past but never this complicated of a project.
Thanks,
Ryan
Have you tried to manually remove all "*.o" files in the directory "obj\Debug\pc\c3\" and re-build the project?
In general, such problems are difficult to solve remotely. If your project is not very secret, then you can send it to me for check. I promise that I will not give it to anyone and will not use it for my own purposes. My e-mail address can be found in the source code of the library.