User forums > Using Code::Blocks

undefined reference to `_imp__* error

(1/2) > >>

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():

--- Code: ---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 );
}
--- End code ---
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)) ===|
--- End quote ---
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?

--- End quote ---

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

Tim S.

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

spflanze:

--- Quote ---Move the #include out of the extern "C" block.
--- End quote ---
I had already tried that. With this change:

--- Code: ---#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 );
}

--- End code ---
The error messages are the same.

stahta01:
Post a full CB rebuild log
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Navigation

[0] Message Index

[#] Next page

Go to full version