Author Topic: undefined reference to `__imp__function@8'|  (Read 3185 times)

Offline Kat B

  • Multiple posting newcomer
  • *
  • Posts: 11
undefined reference to `__imp__function@8'|
« on: April 02, 2009, 08:38:08 am »
Please take some serious pity on me. Please!

I have a workspace with two projects: one a DLL and the other a wxWidgets Frame-based UI utilising the DLL.

Now I can get the DLL to compile and it definately creates a DLL and it also creates a .def.

I can get the wxWidgets UI section to compile and run.

However, when I try to call the exported methods from the DLL in the wxWidgets project, I get errors such as

|72|undefined reference to `__imp__function@8'|

NB: replace 'function' with the actual name of the function.

The only thing I can think of is that somehow I need to tell CodeBlocks about the .def file it creates? How do I do that? Or am I completely wrong and it is something else?

(I have set dependencies between the two projects).

I am scratching my head in serious confusion. I did do some searching (http://forums.codeblocks.org/index.php?topic=8967.0), and there was a reference to a linker option, -Wl,--kill-at  --def=DLT645.def. The documentation for ld doesn't seem to cover that option in depth, unfortunately. (http://www.zap.org.au/elec2041-cdrom/gnutools/doc/gnu-linker.pdf)

How do I set the linker option in Code::Blocks? Despite the fact I have solved my issue, this is still a good question :)

Also, there was a Kerstin that had a similar problem to myself (http://forums.codeblocks.org/index.php/topic,9143.0.html) however, I have absolutely no understanding of what the reply actually meant.

A ha! Got it: I needed to go into Build Options for the wxWidgets project (right clicked on the project name and chose Build Options) and then chose the Linker Settings Tab, and in the Link Libraries section, pressed the Add button and found my dll. And pressed OK.

Was this the correct way? Is there a better/smarter way to do it?

And why does the answer/understanding more often than not come when you have given up yourself and write the question to a forum?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: undefined reference to `__imp__function@8'|
« Reply #1 on: April 03, 2009, 02:38:07 am »
The preferred way is to create an import library along with the DLL (see the target options in your project properties), then link with that import library in Build options -> Linker settings -> Link libraries for your main executable.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)