brechtsanders / xlsxio

XLSX I/O - C library for reading and writing .xlsx files
MIT License
417 stars 112 forks source link

Unresolved external symbol __imp_xlsxioread_open when referenced #70

Closed Michael-lindell closed 4 years ago

Michael-lindell commented 4 years ago

Greetings! I am using the pre-built binary to use with my c project. When I compile my project, the linker is throwing an error at me. More exactly, "Unresolved external symbol __imp_xlsxioread_open".

Furthermore this is the code I have been trying to use that uses your project (Yes, it is from your example code) : //open .xlsx file for reading xlsxioreader xlsxioread; if ((xlsxioread = xlsxioread_open(filename)) == NULL) { fprintf(stderr, "Error opening .xlsx file\n"); return 1; }

Can you help me with this issue?

Best regards, Michael.

brechtsanders commented 4 years ago

Which compiler/linker are you using? Are you building static or shared? It looks like it's looking for the shared symbols. Can you share the exact compile and link statements you use?

Michael-lindell commented 4 years ago

Hi,

What exactly do you mean by "Are you building static or shared?"

FYI, I am using Windows 10 with Visual Studio 2019 and the MSBuild compiler to compile my project. If you are referring to the information under Configuration properties > linker > Command-Line > Additional option in Visual Studio 2019.. This is the compiler and link statement I use :

/OUT:"C:\Users\MichaelLindell\source\repos\read_xlsx_file\Debug\Project1.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Users\MichaelLindell\source\repos\read_xlsx_file\Debug\Project1.pdb" /DYNAMICBASE "C:\Users\MichaelLindell\source\repos\read_xlsx_file\lib\libxlsxio_read.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"C:\Users\MichaelLindell\source\repos\read_xlsx_file\Debug\Project1.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\Project1.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Users\MichaelLindell\source\repos\read_xlsx_file\lib" /TLBID:1

Was that what you were looking for?

brechtsanders commented 4 years ago

I'm focusing more on GCC, so on Windows that's MinGW-w64. But it should build with MSVC if you link with the library correctly. Did you make libxlsxio_read.lib from the .dll and def file from the binary distribution (32-bit/64-bit as needed), or did you build it yourself?

Michael-lindell commented 4 years ago

I see, I made the libxlsxio_read.lib file from the .dll provided from the binary distribution (32-bits) using the "lib-command" and Developer Command prompt for VS 2019.

However, when using the lib command it threw a couple of warnings at me : libxlsxio_read.def(1) : warning LNK4017: ! statement not supported for the target platform; ignored libxlsxio_read.def(2) : warning LNK4017: / statement not supported for the target platform; ignored libxlsxio_read.def(3) : warning LNK4017: xlsxio_read.static.o/ statement not supported for the target platform; ignored libxlsxio_read.def(4) : warning LNK4017: xlsxio_read_sharedstrings.static.o/ statement not supported for the target platform; ignored libxlsxio_read.def(5) : warning LNK4017: /0 statement not supported for the target platform; ignored libxlsxio_read.def(5) : warning LNK4017: L statement not supported for the target platform; ignored libxlsxio_read.def(5) : warning LNK4017: ‹‰$è statement not supported for the target platform; ignored libxlsxio_read.def(5) : warning LNK4017: ‹ statement not supported for the target platform; ignored Creating library libxlsxio_read.lib and object libxlsxio_read.exp

Is this of interest to the issue?

brechtsanders commented 4 years ago

I did a quick search on the web tells me this is how to create the MSVC .lib file (replace x86 with x64 as needed):

lib /def:libxlsxio_read.def /out:libxlsxio_read.lib /machine:x86

But again I'm not an MSVC expert. However if you search stackexchange.com you can find a lot of tibe about this, for example here.

Michael-lindell commented 4 years ago

Hi,

It turned out to be that I was not generating the .def file correctly. I followed your link on stack overflow which pointed me in the right direction and I am now able to generate a .lib file as well as compile my project without any issues.

Thank you for your help and I am closing the issue now!

Best regards, Michael.