Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: spflanze on June 14, 2018, 03:31:00 am

Title: undefined reference to `_imp__* error
Post by: spflanze on June 14, 2018, 03:31:00 am
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 );
}
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?
Title: Re: undefined reference to `_imp__* error
Post by: stahta01 on June 14, 2018, 04:28:33 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.
Title: Re: undefined reference to `_imp__* error
Post by: sodev on June 14, 2018, 05:45:32 am
Move the #include out of the extern "C" block.
Title: Re: undefined reference to `_imp__* error
Post by: spflanze on June 14, 2018, 11:35:10 pm
Quote
Move the #include out of the extern "C" block.
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 );
}
The error messages are the same.
Title: Re: undefined reference to `_imp__* error
Post by: stahta01 on June 15, 2018, 12:06:06 am
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 (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F)
Title: Re: undefined reference to `_imp__* error
Post by: stahta01 on June 15, 2018, 12:31:31 am
Why did you NOT search the source files!!!!!!!!!!

Define CMINPACK_NO_DLL

Tim S.