News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

undefined reference to `_imp__* error

Started by spflanze, June 14, 2018, 03:31:00 AM

Previous topic - Next topic

spflanze

I am integrating the function lmder() from the cminpack package available from
http://devernay.free.fr/hacks/cminpack/
into my C++ wxWidgets based program.

The claim is made there that these files are both C and C++ compatible files, but in this package all I find are .c extensions, so I am integrating them all as C files. When I include the headers from this package I enclose them in the appropriate code indicating these are C headers, and do the same for a function that is to be passed to lmder():
extern "C" {
#include "cminpack.h"
#include "cminpackP.h"
int
//__cminpack_decl_fcnder_mn__
fcn( void *p, int m, int n, const double *x, double *fvec, double *fjac, int ldfjac, int iflag );
}

I get these errors I do not know what to do about:
Quote
obj\Debug\Libraries\cminpack-1.3.6\lmder.o||In function `lmder':|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|216|undefined reference to `_imp__dpmpar'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|245|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|300|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|381|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|396|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|418|undefined reference to `_imp__enorm'|
obj\Debug\Libraries\cminpack-1.3.6\lmder.o:C:\Engineering Software\Libraries\cminpack-1.3.6\lmder.c|466|more undefined references to `_imp__enorm' follow|
obj\Debug\Libraries\cminpack-1.3.6\lmpar.o||In function `lmpar':|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|131|undefined reference to `_imp__dpmpar'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|177|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|207|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|227|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|258|undefined reference to `qrsolv'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|262|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\lmpar.c|306|undefined reference to `_imp__enorm'|
obj\Debug\Libraries\cminpack-1.3.6\qrfac.o||In function `qrfac':|
C:\Engineering Software\Libraries\cminpack-1.3.6\qrfac.c|196|undefined reference to `_imp__dpmpar'|
C:\Engineering Software\Libraries\cminpack-1.3.6\qrfac.c|201|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\qrfac.c|240|undefined reference to `_imp__enorm'|
C:\Engineering Software\Libraries\cminpack-1.3.6\qrfac.c|272|undefined reference to `_imp__enorm'|
obj\Debug\TIA Designer\src\JunctionCap.o||In function `ZN11JunctionCap19CalculateParametersEv':|
C:\Engineering Software\TIA Designer\src\JunctionCap.cpp|249|undefined reference to `_imp__lmder'|
||error: ld returned 1 exit status|
||=== Build failed: 20 error(s), 50 warning(s) (0 minute(s), 24 second(s)) ===|
In these errors the prefix "_imp__" suggest the GCC compiler is compiling these files that are source of these files as C++ files, not C files, in spite of these file's .c extensions. Where in Code::Blocks will I find compiler flags that will do this?

I am attempting to compile these cminpack files as static libraries. So another possibility that has occurred to me is the linker is trying to link as if these were dll files. But in the code I do not see these functions prefixed with __declspec(dllimport) or __declspec(dllexport). Is there another way these files might be marked for linking as if they are dll?

stahta01

Quote from: spflanze on June 14, 2018, 03:31:00 AM
I am attempting to compile these cminpack files as static libraries. So another possibility that has occurred to me is the linker is trying to link as if these were dll files. But in the code I do not see these functions prefixed with __declspec(dllimport) or __declspec(dllexport). Is there another way these files might be marked for linking as if they are dll?

Search for export or import and you will likely find out what to define to make a static build.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

sodev

Move the #include out of the extern "C" block.

spflanze

QuoteMove the #include out of the extern "C" block.
I had already tried that. With this change:
#include "cminpack.h"
#include "cminpackP.h"
extern "C" {
int fcn( void *p, int m, int n, const double *x,
double *fvec, double *fjac, int ldfjac, int iflag );
}

The error messages are the same.

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stahta01

Why did you NOT search the source files!!!!!!!!!!

Define CMINPACK_NO_DLL

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]