golp
golp copied to clipboard
fatal error: lp_lib.h: No such file or directory compilation terminated.
When I trying to use the command to get the package from github, I have the error message popup fatal error: lp_lib.h: No such file or directory compilation terminated.
I installed lp_solve_5.5.2.3_IDE_Setup.exe and retried the command and I still have the problem.
Thanks for the help.
So the core issue is that the C compiler can't find the lp_solve.h file. It's fine to have the lpsolve IDE installed, but I think you'll also need the development dependencies for it (which will include the .h files and .dll files on Windows).
Here's the link for the LPSolve download: https://sourceforge.net/projects/lpsolve/files/lpsolve/5.5.2.3/ . My guess is that you'll want the lp_solve_5.5.2.3_dev_win64.zip
package assuming you have a 64-bit machine.
The next step after extracting that package is to specify how golp
can find the lp_solve library. You could probably store the library in a common location where your C compiler (maybe MinGW?) can find it on its default library loading path.
You can also modify the golp
source code to specify where the library is for Windows (there are already defaults for Mac and Linux): https://github.com/draffensperger/golp/blob/master/lp.go#L23
If you figure out a standardized way to do the installation and setting up the path, a pull request for how to get this working on Windows is welcome :)
Hi Dave, I have TDM-GCC installed on my computer and I put the extracted file into the C:\TDM-GCC-64\x86_64-w64-mingw32\include folder. Seems the go builder can find the file but there are many errors now as indicated below:
C:/xxKun_Learn/Go/Go/src/github.com/draffensperger/golp/lp.go:86: undefined reference to add_constraint' C:\Users\Kun\AppData\Local\Temp\go-build979408354\github.com\draffensperger\golp\_obj\lp.cgo2.o: In function
_cgo_e1eff468c2e4_Cfunc_add_constraintex':
C:/xxKun_Learn/Go/Go/src/github.com/draffensperger/golp/lp.go:107: undefined reference to add_constraintex' C:\Users\Kun\AppData\Local\Temp\go-build979408354\github.com\draffensperger\golp\_obj\lp.cgo2.o: In function
_cgo_e1eff468c2e4_Cfunc_get_Ncolumns':
C:/xxKun_Learn/Go/Go/src/github.com/draffensperger/golp/lp.go:139: undefined reference to get_Ncolumns' C:\Users\Kun\AppData\Local\Temp\go-build979408354\github.com\draffensperger\golp\_obj\lp.cgo2.o: In function
_cgo_e1eff468c2e4_Cfunc_get_Nrows':
OK, yeah, it looks like it's able to find the .h
file, but is having trouble finding the actual functions. That's the job of the C linker to actually wire up the function calls with the external dependencies. If you are seeking to compile it statically, you would want to make sure that the C compiler can find the relevant .lib
file for lp_solve (extension on windows for static libs), or if you want it to link dynamically to lp_solve, you'll need to let the compiler find the .dll
file for lp_solve during linking but also make sure that the executable can find it during execution time (perhaps by putting the dll in the same folder as your project or in a shared system dll folder).
Hi Dave, thanks for the suggestion. Now it can find the file but error happens again!
github.com/draffensperger/golp C:/xxKun_Learn/Go/Go/src/github.com/draffensperger/golp/lpsolve55.lib: error adding symbols: File in wrong format collect2.exe: error: ld returned 1 exit status
i found it is really hard to make it run lol.. Thanks again
Hmm.. could it be that you downloaded the wrong lp_solve55 for your machine architecture (64-bit when you have a 32-bit machine)?
Yeah, getting dependencies linked together can be a lot of work in itself for sure! I think you are on the right track though. I would suggest Googling that error to try researching that message specifically for your C compiler/linker which might give new ideas.
Hi Dave, my computer and my softewares should be 64 bits. I think I need find which compiler go uses
I'm not too familiar with Go on Windows, but is it possible that it had you install the MinGW compiler (see https://github.com/golang/go/wiki/WindowsBuild#install-mingwmsys)?
One suggestion would be to try to get a very simple C program compiled that uses lpsolve (e.g. the demo.c
file from this page: http://lpsolve.sourceforge.net/5.5/formulate.htm) and then once you have that working you will know for sure that your C compiler can properly integrate with lpsolve and that the dependencies are correctly.
Then you can perhaps better investigate why the go build toochain (which invokes a C compiler) is having trouble with it.
Hey, I tried installing golp in my ubuntu 14.04 machine. I have added lpsolve
folder and installed the dependencies. I also did sudo apt-get install liblpsolve55-dev
but when I run the code I get following error. Don't understand what the problem is.
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblpsolve55.a(lp_lib.o): In function `set_BFP':
(.text+0x37a0): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblpsolve55.a(lp_lib.o): In function `set_BFP':
(.text+0x385f): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblpsolve55.a(lp_lib.o): In function `set_BFP':
(.text+0x387c): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblpsolve55.a(lp_lib.o): In function `set_BFP':
(.text+0x3b8d): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblpsolve55.a(lp_lib.o): In function `set_BFP':
(.text+0x3ba5): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblpsolve55.a(lp_lib.o): In function `set_BFP':
(.text+0x3bbd): undefined reference to `dlsym'
Thanks for your interest in the library and for bringing this up. I run on a Mac currently but will plan to spin up an Ubuntu 14.04 VM instance and see if I can reproduce that for you.
Was anyone ever able to reproduce/solve that undefined reference to dlclose
error? I've been using this package to great effect on my Mac but I'm looking to move it to a Linux system and can't get it working. Something is missing but I've got no idea what's going on once we get underneath the Go layer...
If you figure out a standardized way to do the installation and setting up the path, a pull request for how to get this working on Windows is welcome :)
I have opened a new pull request (https://github.com/draffensperger/golp/pull/12) to do it!