0

I'm trying to get some C code to compile (dump1090, an SDR/ADS-B receiver application), but cannot figure out how to fix the "undefined reference to xxxx" where xxxx is a function name in an external library (DLL). The external library is rtl-sdr and there are two header files. The DLL is referenced using __declspec(dllexport). I am using Code::Blocks on Windows 10; I have the DLL in the bin\debug folder. Although I'm a long-term programmer (mostly C#), I'm not that familiar with C.

Pete Jones
  • 46
  • 7
  • 1
    Does the external library come with an actual *library* file (e.g. `rtl-sdl.lib` or similar)? Then you need to *link* with that library. – Some programmer dude Feb 19 '20 at 12:44
  • "The DLL is referenced using __declspec(dllexport)" - if you're linking it in, these need to be `__declspec(dllimport)` not export. The usual pattern is to hide the __declspec behind a define that switches between import or export depending on another define used only when compiling the DLL. – Rup Feb 19 '20 at 12:45
  • There is no lib file unfortunately. – Pete Jones Feb 19 '20 at 13:09
  • There is a conditional import/export, sorry I forgot to mention that. – Pete Jones Feb 19 '20 at 13:10
  • 1
    "There is no lib file unfortunately." - then you need to make one: [How to generate an import library (LIB-file) from a DLL?](https://stackoverflow.com/questions/9946322/how-to-generate-an-import-library-lib-file-from-a-dll) or [How to make a .lib file when have a .dll file and a header file](https://stackoverflow.com/questions/9360280/how-to-make-a-lib-file-when-have-a-dll-file-and-a-header-file) – Rup Feb 19 '20 at 13:26
  • Thanks, will try that now. – Pete Jones Feb 19 '20 at 13:36
  • That worked a treat, thanks very much. – Pete Jones Feb 19 '20 at 14:39

0 Answers0