Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with linking shared libraries using Code::Blocks and CoolProp #853

Closed
loupgarou2109 opened this issue Oct 27, 2015 · 27 comments
Closed
Milestone

Comments

@loupgarou2109
Copy link

Hello,

I'm new to C++-programming and I need to add the functionality of CoolProp to a turbomachinery problem. I used to add CoolProp to EXCEL and I loved it. What I wanted to do now is linking a shared library as described in here

First, I downloaded the precompiled versions with the cdecl-calling conventions. As described in here, I've been putting the CoolPropLib.h in an "include" directory, the CoolProp.lib in a "lib" directory and the CoolProp.dll in the directory where the main-file is located.

After that, I told Code::Blocks where to find the ".lib" and the ".h"-files (as a relative path).

When I use the C++ sample code from the CoolProp website:

#include "CoolProp.h"
#include <iostream>
using namespace CoolProp;
int main()
{
    // First type (slowest, due to most string processing, exposed in DLL)
    std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
    std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
    std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;

    std::vector<double> z(2,0.5);
    // Second type (C++ only, a bit faster, allows for vector inputs and outputs)
    std::vector<std::string> fluids; fluids.push_back("Propane"); fluids.push_back("Ethane");
    std::vector<std::string> outputs; outputs.push_back("Dmolar");
    std::vector<double> T(1,298), p(1e5);
    std::cout << PropsSImulti(outputs,"T", T, "P", p, "", fluids, z)[0][0] << std::endl;
    std::cout << PropsSImulti(outputs,"T", T, "P", p, "HEOS", fluids, z)[0][0] << std::endl;
    std::cout << PropsSImulti(outputs,"T", T, "P", p, "REFPROP", fluids, z)[0][0] << std::endl;

    return EXIT_SUCCESS;
}

I get these error messages:

-------------- Build: Debug in Compressor_Prediction (compiler: GNU GCC
Compiler)---------------

mingw32-g++.exe -Llib
-LD:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\lib
-o bin\Debug\Compressor_Prediction.exe obj\Debug\igv.o obj\Debug\main.o
obj\Debug\main.o:main.cpp:(.text+0x18a): undefined reference to `CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
obj\Debug\main.o:main.cpp:(.text+0x38b): undefined reference to `CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
obj\Debug\main.o:main.cpp:(.text+0x58c): undefined reference to `CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
obj\Debug\main.o:main.cpp:(.text+0xa01): undefined reference to `CoolProp::PropsSImulti(std::vector<std::string,
std::allocator<std::string> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<double, std::allocator<double> > const&)'
obj\Debug\main.o:main.cpp:(.text+0xbb7): undefined reference to `CoolProp::PropsSImulti(std::vector<std::string,
std::allocator<std::string> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<double, std::allocator<double> > const&)'
obj\Debug\main.o:main.cpp:(.text+0xd67): undefined reference to `CoolProp::PropsSImulti(std::vector<std::string,
std::allocator<std::string> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<double, std::allocator<double> > const&)'
collect2.exe: error: ld returned 1 exit status Process terminated with status 1 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))

It seems to be a problem with correct lib-linking. I also tried to compile the shared library by myself. When I managed to do so, I get the same error messages.

I can imagine quite well that this seems to be a trivial problem, but I'm soon to despair and I feel that I forgot something.

I would appreciate if anybody could help me.

Thanks in advance
Clemens

@ibell
Copy link
Contributor

ibell commented Oct 27, 2015

Correct. On windows you want to build a STATIC library, not a shared
library. Trust me on this :)

I added some more information on C++ applications to the development
documentation:
http://www.coolprop.dreamhosters.com/binaries/sphinx/coolprop/wrappers/StaticLibrary/index.html#static-library

Basically, you need to
a) Build a static(!) library using Mingw
b) Link the MINGW static library to your application.

Just a warning, your static library will be quite huge, see this issue:
#828

On Tue, Oct 27, 2015 at 11:18 AM, loupgarou2109 notifications@github.com
wrote:

Hello,

I'm new to C++-programming and I need to add the functionality of CoolProp
to a turbomachinery problem. I used to add CoolProp to EXCEL and I loved
it. What I wanted to do now is linking a shared library as described in
here http://www.coolprop.org/coolprop/wrappers/SharedLibrary/index.html

First, I downloaded the precompiled versions with the cdecl-calling
conventions. As described in here
http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/,
I've been putting the CoolPropLib.h in an "include" directory, the
CoolProp.lib in a "lib" directory and the CoolProp.dll in the directory
where the main-file is located.

After that, I told Code::Blocks where to find the ".lib" and the
".h"-files (as a relative path).

When I use the C++ sample code from the CoolProp website:

#include "CoolProp.h"
#include using namespace CoolProp;int main()
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;

std::vector<double> z(2,0.5);
// Second type (C++ only, a bit faster, allows for vector inputs and outputs)
std::vector<std::string> fluids; fluids.push_back("Propane"); fluids.push_back("Ethane");
std::vector<std::string> outputs; outputs.push_back("Dmolar");
std::vector<double> T(1,298), p(1e5);
std::cout << PropsSImulti(outputs,"T", T, "P", p, "", fluids, z)[0][0] << std::endl;
std::cout << PropsSImulti(outputs,"T", T, "P", p, "HEOS", fluids, z)[0][0] << std::endl;
std::cout << PropsSImulti(outputs,"T", T, "P", p, "REFPROP", fluids, z)[0][0] << std::endl;

return EXIT_SUCCESS;

}

I get these error messages:

-------------- Build: Debug in Compressor_Prediction (compiler: GNU GCC
Compiler)---------------

mingw32-g++.exe -Llib
-LD:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\lib
-o bin\Debug\Compressor_Prediction.exe obj\Debug\igv.o obj\Debug\main.o
obj\Debug\main.o:main.cpp:(.text+0x18a): undefined reference to CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)' obj\Debug\main.o:main.cpp:(.text+0x38b): undefined reference toCoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
obj\Debug\main.o:main.cpp:(.text+0x58c): undefined reference to CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)' obj\Debug\main.o:main.cpp:(.text+0xa01): undefined reference toCoolProp::PropsSImulti(std::vector<std::string,
std::allocatorstd::string > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, std::vector<double, std::allocator > const&)'
obj\Debug\main.o:main.cpp:(.text+0xbb7): undefined reference to CoolProp::PropsSImulti(std::vector<std::string, std::allocator<std::string> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<double, std::allocator<double> > const&)' obj\Debug\main.o:main.cpp:(.text+0xd67): undefined reference toCoolProp::PropsSImulti(std::vector<std::string,
std::allocatorstd::string > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, std::vector<double, std::allocator > const&)'
collect2.exe: error: ld returned 1 exit status Process terminated with status 1 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))

It seems to be a problem with correct lib-linking. I also tried to compile
the shared library by myself. When I managed to do so, I get the same error
messages.

I can imagine quite well that this seems to be a trivial problem, but I'm
soon to despair and I feel that I forgot something.

I would appreciate if anybody could help me.

Thanks in advance
Clemens


Reply to this email directly or view it on GitHub
#853.

@ibell
Copy link
Contributor

ibell commented Oct 27, 2015

Hopefully the instructions on that page get you going. Any issues, please
report, and if there are things that could be more clear, that is also
useful information.

On Tue, Oct 27, 2015 at 11:23 AM, Ian Bell ian.h.bell@gmail.com wrote:

Correct. On windows you want to build a STATIC library, not a shared
library. Trust me on this :)

I added some more information on C++ applications to the development
documentation:
http://www.coolprop.dreamhosters.com/binaries/sphinx/coolprop/wrappers/StaticLibrary/index.html#static-library

Basically, you need to
a) Build a static(!) library using Mingw
b) Link the MINGW static library to your application.

Just a warning, your static library will be quite huge, see this issue:
#828

On Tue, Oct 27, 2015 at 11:18 AM, loupgarou2109 notifications@github.com
wrote:

Hello,

I'm new to C++-programming and I need to add the functionality of
CoolProp to a turbomachinery problem. I used to add CoolProp to EXCEL and I
loved it. What I wanted to do now is linking a shared library as described
in here
http://www.coolprop.org/coolprop/wrappers/SharedLibrary/index.html

First, I downloaded the precompiled versions with the cdecl-calling
conventions. As described in here
http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/,
I've been putting the CoolPropLib.h in an "include" directory, the
CoolProp.lib in a "lib" directory and the CoolProp.dll in the directory
where the main-file is located.

After that, I told Code::Blocks where to find the ".lib" and the
".h"-files (as a relative path).

When I use the C++ sample code from the CoolProp website:

#include "CoolProp.h"
#include using namespace CoolProp;int main()
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;

std::vector<double> z(2,0.5);
// Second type (C++ only, a bit faster, allows for vector inputs and outputs)
std::vector<std::string> fluids; fluids.push_back("Propane"); fluids.push_back("Ethane");
std::vector<std::string> outputs; outputs.push_back("Dmolar");
std::vector<double> T(1,298), p(1e5);
std::cout << PropsSImulti(outputs,"T", T, "P", p, "", fluids, z)[0][0] << std::endl;
std::cout << PropsSImulti(outputs,"T", T, "P", p, "HEOS", fluids, z)[0][0] << std::endl;
std::cout << PropsSImulti(outputs,"T", T, "P", p, "REFPROP", fluids, z)[0][0] << std::endl;

return EXIT_SUCCESS;

}

I get these error messages:

-------------- Build: Debug in Compressor_Prediction (compiler: GNU GCC
Compiler)---------------

mingw32-g++.exe -Llib
-LD:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\lib
-o bin\Debug\Compressor_Prediction.exe obj\Debug\igv.o obj\Debug\main.o
obj\Debug\main.o:main.cpp:(.text+0x18a): undefined reference to CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)' obj\Debug\main.o:main.cpp:(.text+0x38b): undefined reference toCoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
obj\Debug\main.o:main.cpp:(.text+0x58c): undefined reference to CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)' obj\Debug\main.o:main.cpp:(.text+0xa01): undefined reference toCoolProp::PropsSImulti(std::vector<std::string,
std::allocatorstd::string > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, std::vector<double, std::allocator > const&)'
obj\Debug\main.o:main.cpp:(.text+0xbb7): undefined reference to CoolProp::PropsSImulti(std::vector<std::string, std::allocator<std::string> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<double, std::allocator<double> > const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<double, std::allocator<double> > const&)' obj\Debug\main.o:main.cpp:(.text+0xd67): undefined reference toCoolProp::PropsSImulti(std::vector<std::string,
std::allocatorstd::string > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<double, std::allocator > const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, std::vector<double, std::allocator > const&)'
collect2.exe: error: ld returned 1 exit status Process terminated with status 1 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))

It seems to be a problem with correct lib-linking. I also tried to
compile the shared library by myself. When I managed to do so, I get the
same error messages.

I can imagine quite well that this seems to be a trivial problem, but I'm
soon to despair and I feel that I forgot something.

I would appreciate if anybody could help me.

Thanks in advance
Clemens


Reply to this email directly or view it on GitHub
#853.

@loupgarou2109
Copy link
Author

Wow, thank you very much for this incredibly quick response. I will try to do so and then inform you.

@loupgarou2109
Copy link
Author

Sadly, I still have the same problem. I built the static library as mentioned, which is very large indeed. After that I told Code::Blocks where to find it, but it's still this message:

mingw32-g++.exe -Llib -LD:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\lib -o bin\Debug\Compressor_Prediction.exe obj\Debug\igv.o obj\Debug\main.o
obj\Debug\main.o:main.cpp:(.text+0x13f): undefined reference to `CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
collect2.exe: error: ld returned 1 exit status

@ibell
Copy link
Contributor

ibell commented Oct 27, 2015

A few small comments:

  1. While I didn't mention it above, make sure you use the MinGW generator
    when building the static library so that it uses GCC instead of visual
    studio to build the static library. If your static library is very large,
    you probably did it properly :)
  2. Your Code::Blocks project doesn't seem to link the static library - it's
    not listed in the command line call. There should be something like a
    -lCoolProp argument in there. Linking a static library is a
    combination of either providing linking directory and library name OR an
    absolute path to the static library

I'm sure we'll get it and you are almost there.

@loupgarou2109
Copy link
Author

Yes, I think that's the point. When I specify the path to the library, Code::Blocks puts it at the end of the compilation order. I guess the path to the libraries and the library itself must be known before the debugger starts. I actually don't know how to fix that, but it seems to be a C::B related issue.

@ibell
Copy link
Contributor

ibell commented Oct 27, 2015

Hmm I seem to recall as well that in Code::Blocks you could link it with
several different versions of GCC, perhaps you have picked up the wrong
one? And your static library doesn't link properly?

Are you able to compile properly now? Setting debugger search directories
is the next step if you can get compilation to work.

On Tue, Oct 27, 2015 at 3:27 PM, loupgarou2109 notifications@github.com
wrote:

Yes, I think that's the point. When I specify the path to the library,
Code::Blocks puts it at the end of the compilation order. I guess the path
to the libraries and the library itself must be known before the debugger
starts. I actually don't know how to fix that, but it seems to be a C::B
related issue.


Reply to this email directly or view it on GitHub
#853 (comment).

@loupgarou2109
Copy link
Author

I'm using the TDM-GCC Compiler (4.7.1). Even though I linked the static library as described in several sources, it doesn't work. Even though there is a -lCoolProp in the log-file now.

mingw32-g++.exe -Llibs -o bin\Debug\Compressor_Prediction.exe
obj\Debug\main.o -lCoolProp
obj\Debug\main.o:main.cpp:(.text+0x13f): undefined reference to `CoolProp::PropsSI(std::string const&, std::string const&, double, std::string const&, double, std::string const&)'
collect2.exe: error: ld returned 1 exit status

@loupgarou2109
Copy link
Author

Sorry, I have to ask again some questions: when I build the static library in the directory "C:/user/name/CoolProp/build", which files do I have to copy in my project directory "D:/path/to/directory". What's the name of the Headerfile that I need for the static library? Do I have to put the headerfile into an input directory in my project directory? And the .a-file which was build into the lib directory? Or do I need the whole source directories?

It seems that I don't understand why I need to build my own library, when there are precompiled ones here. Where is the difference? And why do they don't work, when I put the headerfile CoolPropLib.h from the static libraries directory on sourceforge into my include-directory and the CoolProp.lib from the Windows subdirectory into the lib subdirectory from my project?

Sorry, so much questions...

@jowr
Copy link
Member

jowr commented Oct 28, 2015

I am not a Windows guru, but there are two things here:

  • Make sure that do not mix different compilers. I might be wrong here, but I do not think that MinGW and VisualStudio work well together. *.lib = static library from VisualStudio and *.a=static library from MinGW. You probably do not want to use both at the same time.
  • An undefined reference error could indicate that there is a header file missing. Could you please start by compiling the example files before you report errors that might originate from your code? You gave some example code earlier, does that part work now?

@loupgarou2109
Copy link
Author

No, unfortunately the example code still doesn't work.

@ibell
Copy link
Contributor

ibell commented Oct 28, 2015

When you try to compile the minimal example at the link above at the
command line without Code::Blocks? That should be step #1, Jorrit is right
about that.

On Wed, Oct 28, 2015 at 2:04 PM, loupgarou2109 notifications@github.com
wrote:

No, unfortunately the example code still doesn't work.


Reply to this email directly or view it on GitHub
#853 (comment).

@loupgarou2109
Copy link
Author

Thank you very much for your help and time. Unfortunately, it also doesn't work when I compile it from the command line:

D:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\Comp_Pred>g++
 -Iinclude -Llib -o main main.cpp -lCoolProp
lib/libCoolProp.a(CoolProp.cpp.obj): In function `strtod':
C:/TDM-GCC-64/x86_64-w64-mingw32/include/stdlib.h:399: undefined reference to `_
_mingw_strtod'
lib/libCoolProp.a(AbstractState.cpp.obj): In function `ZN5Eigen15PlainObjectBase
INS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEEE6resizeEii':
C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/PlainObjectBase.h:249:
undefined reference to `_wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In function `ZN5Eigen8internal10Assign
mentINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEES3_NS0_9assign_opIdEENS0_11Dense2Dens
eEdE3runERS3_RKS3_RKS5_':
C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/AssignEvaluator.h:761:
undefined reference to `_wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In function `ZN5Eigen8internal26call_d
ense_assignment_loopINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEES3_NS0_9assign_opIdEE
EEvRKT_RKT0_RKT1_':
C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/AssignEvaluator.h:627:
undefined reference to `_wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In function `ZN5Eigen15PlainObjectBase
INS_5ArrayIdLin1ELi1ELi0ELin1ELi1EEEE6resizeEii':
C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/PlainObjectBase.h:249:
undefined reference to `_wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In function `ZN5Eigen8internal10Assign
mentINS_5ArrayIdLin1ELi1ELi0ELin1ELi1EEES3_NS0_9assign_opIdEENS0_11Dense2DenseEd
E3runERS3_RKS3_RKS5_':
C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/AssignEvaluator.h:761:
undefined reference to `_wassert'
lib/libCoolProp.a(AbstractState.cpp.obj):C:/Users/Clemens/CoolProp/externals/Eig
en/Eigen/src/Core/AssignEvaluator.h:627: more undefined references to `_wassert'
 follow
collect2.exe: error: ld returned 1 exit status

@loupgarou2109
Copy link
Author

The main-file contains the minimum expample:

#include "CoolProp.h"
#include <iostream>

int main()
{
    std::cout << CoolProp::PropsSI("T","P",101325,"Q",0,"Water") << std::endl;
    return 1;
}

@ibell
Copy link
Contributor

ibell commented Oct 28, 2015

Can you please try to do EXACTLY as in the static library page first?
Include paths, etc.?

Also, I think your MINGW is a bit too old, I think you need at least 4.9 if
I am not mistaken

On Wed, Oct 28, 2015 at 2:33 PM, loupgarou2109 notifications@github.com
wrote:

Thank you very much for your help and time. Unfortunately, it also doesn't
work when I compile it from the command line:

D:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\Comp_Pred>g++
-Iinclude -Llib -o main main.cpp -lCoolProp
lib/libCoolProp.a(CoolProp.cpp.obj): In function strtod': C:/TDM-GCC-64/x86_64-w64-mingw32/include/stdlib.h:399: undefined reference to_
_mingw_strtod'
lib/libCoolProp.a(AbstractState.cpp.obj): In function ZN5Eigen15PlainObjectBase INS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEEE6resizeEii': C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/PlainObjectBase.h:249: undefined reference to_wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In function ZN5Eigen8internal10Assign mentINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEES3_NS0_9assign_opIdEENS0_11Dense2Dens eEdE3runERS3_RKS3_RKS5_': C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/AssignEvaluator.h:761: undefined reference to _wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In functionZN5Eigen8internal26call_d ense_assignment_loopINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEES3_NS0_9assign_opIdEE EEvRKT_RKT0_RKT1_': C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/AssignEvaluator.h:627: undefined reference to _wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In functionZN5Eigen15PlainObjectBase INS_5ArrayIdLin1ELi1ELi0ELin1ELi1EEEE6resizeEii': C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/PlainObjectBase.h:249: undefined reference to _wassert'
lib/libCoolProp.a(AbstractState.cpp.obj): In functionZN5Eigen8internal10Assign mentINS_5ArrayIdLin1ELi1ELi0ELin1ELi1EEES3_NS0_9assign_opIdEENS0_11Dense2DenseEd E3runERS3_RKS3_RKS5_': C:/Users/Clemens/CoolProp/externals/Eigen/Eigen/src/Core/AssignEvaluator.h:761: undefined reference to _wassert'
lib/libCoolProp.a(AbstractState.cpp.obj):C:/Users/Clemens/CoolProp/externals/Eig
en/Eigen/src/Core/AssignEvaluator.h:627: more undefined references to`_wassert'
follow
collect2.exe: error: ld returned 1 exit status


Reply to this email directly or view it on GitHub
#853 (comment).

@jowr
Copy link
Member

jowr commented Oct 28, 2015

just a shot in the dark, but did you try -std=c++11 as compiler option? Could it be related to the standard libraries? Did you try -lstdc++?

@loupgarou2109
Copy link
Author

@ibell I'm using MinGW version 5.1:

D:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\Comp_Pred>g++
 --version
g++ (tdm-1) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.

When I compile exactly as mentioned in the static library page, I get another error:

D:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\Comp_Pred>g++
 -lCoolProp -ldl -Llib -Iinclude main.cpp
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../../mingw32/bin/ld.exe: canno
t find -ldl
collect2.exe: error: ld returned 1 exit status

@jowr
Copy link
Member

jowr commented Oct 28, 2015

The page refers to Linux and MacOS and not to Windows with MinGW. Windows handles libraries differently and that is why youy probably do not need -ldl.

@loupgarou2109
Copy link
Author

Okay. When I don't use it, i get this error message:

D:\Maschinenbau\Diplom\Diplomarbeit\Programm\Compressor_Prediction\Comp_Pred>g++
 -lCoolProp -Llib -Iinclude main.cpp
C:\Users\Clemens\AppData\Local\Temp\cc4E9Cim.o:main.cpp:(.text+0x14c): undefined
 reference to `CoolProp::PropsSI(std::__cxx11::basic_string<char, std::char_trai
ts<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::c
har_traits<char>, std::allocator<char> > const&, double, std::__cxx11::basic_str
ing<char, std::char_traits<char>, std::allocator<char> > const&, double, std::__
cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
'
collect2.exe: error: ld returned 1 exit status

@jowr
Copy link
Member

jowr commented Oct 28, 2015

Why does it not find the library? It seems that you made a step back compared to #853 (comment) . Check your include paths. Is the *.a file in the lib directory? Do you know anyone that knows C++? It looks like we are are fighting with the setup of your machine...

@ibell
Copy link
Contributor

ibell commented Oct 28, 2015

Might be a question of the standard library. I can take a look this
evening.

On Wed, Oct 28, 2015 at 3:14 PM, Jorrit Wronski notifications@github.com
wrote:

Why does it not find the library? It seems that you made a step back
compared to #853 (comment)
#853 (comment)
. Check your include paths. Is the *.a file in the lib directory? Do you
know anyone that knows C++? It looks like we are are fighting with the
setup of your machine...


Reply to this email directly or view it on GitHub
#853 (comment).

@loupgarou2109
Copy link
Author

Thanks a lot for your help.
@jowr The *.a file ist stil in the lib-directory. I guess asking somebody to watch my system setup might be the best idea at this point of state. I installed and deinstalled many different compilers the last days, maybe they don't coexist happily together.

@ibell
Copy link
Contributor

ibell commented Oct 28, 2015

I confirm problem linking with MINGW build on windows, with same linking error. I'm on it.

@ibell
Copy link
Contributor

ibell commented Oct 28, 2015

Ok, so the problem is linking order. The -lCoolProp needs to be after the .cpp file, like so:

g++ -L. -I../../include main.cpp -lCoolProp

See also http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use

@loupgarou2109
Copy link
Author

IT WORKS!!! 😄 Thanks for your help.

What I was doing: I uninstalled all compilers I have been installing over the last days when trying to compile the example file (MinGW original "older" release version 4.x or so, TDM-32 5.1, TDM-64 5.1), deleted all path variables from my environment referring to GCC compilers (of which there have been many) and reinstalled TDM-GCC-64.

On the command line, I added -lCoolProp AND -m32 at the end, otherwise there would be an error message which says that the ld.exe skipped incompatible libs (I guess it had something to do with the compiler version I used to build the static library).

Now I just have to tell Code::Blocks to use the TDM-64 compiler and add the option -m32 to the compiler. But that's another story.

So far: thank you very very much!

@jowr
Copy link
Member

jowr commented Oct 29, 2015

Great, good to hear it works. Please close this issue as soon as you are in business.

@ibell ibell added this to the v5.1.2 milestone Nov 14, 2015
@28tanuj
Copy link

28tanuj commented Apr 24, 2020

I know this would be a difficult task after such long time but, can you please share the final code with the changes that you made? That would be very helpful. Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants