[Build] Generate invalid file ?

38 views
Skip to first unread message

remi.de...@gmail.com

unread,
Nov 16, 2018, 5:01:08 AM11/16/18
to OSQP
Hi evryone,

I just build osqp for windows.
In my project I add lib path ".\lib" and the AdditionalDependencies "libosqp.dll"
But when I build project I have this error.

"\lib\libosqp.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x480"

Anyone have a solution ?

Goran Banjac

unread,
Nov 16, 2018, 5:09:32 AM11/16/18
to OSQP
Can you provide more information on how you built OSQP? Which compiler did you use? Can you run osqp_demo.exe after building OSQP?

Goran

remi.de...@gmail.com

unread,
Nov 16, 2018, 5:13:39 AM11/16/18
to OSQP
I build with this information : https://osqp.org/docs/get_started/sources.html

Install TDM-GCC 64bit.
Install the latest CMake.

git clone --recursive https://github.com/oxfordcontrol/osqp
cd osqp
git pull
cmake -G "MinGW Makefiles" ..
cmake --build %cd%

I just run osqp_demo and the result is.

-----------------------------------------------------------------
OSQP v0.4.1 - Operator Splitting QP Solver
(c) Bartolomeo Stellato, Goran Banjac
University of Oxford - Stanford University 2018
-----------------------------------------------------------------
problem: variables n = 2, constraints m = 3
nnz(P) + nnz(A) = 7
settings: linear system solver = qdldl,
eps_abs = 1.0e-003, eps_rel = 1.0e-003,
eps_prim_inf = 1.0e-004, eps_dual_inf = 1.0e-004,
rho = 1.00e-001 (adaptive),
sigma = 1.00e-006, alpha = 1.60, max_iter = 4000
check_termination: on (interval 25),
scaling: on, scaled_termination: off
warm start: on, polish: off

iter objective pri res dua res rho time
1 -7.8808e-003 1.01e+000 2.00e+002 1.00e-001 1.97e-004s
25 1.8797e+000 1.60e-003 9.48e-004 1.00e-001 4.91e-004s

status: solved
number of iterations: 25
optimal objective: 1.8797
run time: 7.78e-004s
optimal rho estimate: 2.14e-001

Paul Goulart

unread,
Nov 16, 2018, 5:38:32 AM11/16/18
to remi.de...@gmail.com, OSQP
I suspect that you want to link against libosqp.lib, not libosqp.dll. I don’t have a Windows box to confirm on though.

PG
> --
> You received this message because you are subscribed to the Google Groups "OSQP" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to osqp+uns...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/osqp/6e79ab68-a52e-46c3-a251-c40e7030c8d5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

remi.de...@gmail.com

unread,
Nov 16, 2018, 5:52:31 AM11/16/18
to OSQP
Ho yes... dll don't have a same use that lib...
I practice very little cpp normally I program in python and I still struggle with the management of libraries

So I have to find how to use a dll in my project. Or it's possible to easy set cmake for build lib file ?

Goran Banjac

unread,
Nov 16, 2018, 6:07:12 AM11/16/18
to OSQP
Since you are able to run osqp_demo.exe, it means that the static library was linked successfully.

You can try to change the following line:
with
target_link_libraries (osqp_demo osqp)
to make sure you can link the dynamic library as well.

If you are still able to run osqp_demo.exe, then probably nothing is wrong with the libraries you generate.

remi.de...@gmail.com

unread,
Nov 16, 2018, 6:23:59 AM11/16/18
to OSQP
Thanks for your help Goran,

I deleted all files in build directory, change given line, re generate project 'cmake -G "MinGW Makefiles" ..' and re build "cmake --build %cd%"

osqp_demo.exe works fine but I have a same error on my project.

remi.de...@gmail.com

unread,
Nov 16, 2018, 6:33:36 AM11/16/18
to OSQP
Oh i saw on internet *.a file is like *.lib file but for unix system.
osqp_demo works but it's not possible to use libosqp.a ile with visual studio

Goran Banjac

unread,
Nov 16, 2018, 6:34:47 AM11/16/18
to OSQP
CMake already builds the libraries. You can find them in the build\out directory.

You just need to learn how to use them and this depends on your build environment. As you can see in CMakeLists.txt, this is really easy with CMake.

Goran Banjac

unread,
Nov 16, 2018, 6:45:30 AM11/16/18
to OSQP
If you want to use the libraries within Visual Studio, then you should specify the appropriate compiler with CMake.

For instance, instead of running
cmake -G "MinGW Makefiles" ..
you can run
cmake -G "Visual Studio 15 2017 Win64" ..

You can find the list of all supported compilers if you run
cmake --help

remi.de...@gmail.com

unread,
Nov 16, 2018, 8:17:40 AM11/16/18
to OSQP
Oh yeah ! that works :)

but osqp_demo.exe doesn't build but I have dll/lib files and my project build !

Thanks for your help !

Goran Banjac

unread,
Nov 16, 2018, 8:58:56 AM11/16/18
to OSQP
osqp_demo.exe should be in the build\out\Debug directory.

remi.de...@gmail.com

unread,
Nov 16, 2018, 9:22:57 AM11/16/18
to OSQP
The first time I build osqp_demo doesn't build. I had a error message. But for show you the error a I restarted build and now is OK...

So i deleted all build directory and restart full process.
The first time I have error and second time build is OK...

ÉCHEC de la build.

"D:\Work\ToBuild\osqp\build\ALL_BUILD.vcxproj" (cible par défaut) (1) ->
"D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj" (cible par défaut) (4) ->
(ClCompile cible) ->
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_2.c(1525): warning C4244: '=' : conversion de '__int64' en 'c_f
loat', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_2.c(1526): warning C4244: '=' : conversion de '__int64' en 'c_f
loat', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_2.c(1563): warning C4244: '=' : conversion de '__int64' en 'c_f
loat', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_2.c(1593): warning C4244: '=' : conversion de '__int64' en 'c_f
loat', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_2.c(1599): warning C4244: '=' : conversion de '__int64' en 'c_f
loat', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_aat.c(176): warning C4244: '=' : conversion de '__int64' en 'c_
float', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_aat.c(177): warning C4244: '=' : conversion de '__int64' en 'c_
float', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_aat.c(179): warning C4244: '=' : conversion de '__int64' en 'c_
float', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_aat.c(180): warning C4244: '=' : conversion de 'size_t' en 'c_f
loat', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_order.c(47): warning C4244: '=' : conversion de '__int64' en 'c
_float', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_order.c(66): warning C4244: '=' : conversion de '__int64' en 'c
_float', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\amd\src\amd_order.c(197): warning C4244: '=' : conversion de '__int64' en '
c_float', perte possible de données [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\qdldl_interface.c(325): warning C4101: 'kk' : variable locale non référencé
e [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]
d:\work\tobuild\osqp\lin_sys\direct\qdldl\qdldl_interface.c(342): warning C4101: 'kk' : variable locale non référencé
e [D:\Work\ToBuild\osqp\build\lin_sys\direct\qdldl\linsys_qdldl.vcxproj]


"D:\Work\ToBuild\osqp\build\ALL_BUILD.vcxproj" (cible par défaut) (1) ->
"D:\Work\ToBuild\osqp\build\osqp.vcxproj" (cible par défaut) (5) ->
d:\work\tobuild\osqp\src\osqp.c(454): warning C4244: 'fonction' : conversion de 'c_int' en 'double', perte possible d
e données [D:\Work\ToBuild\osqp\build\osqp.vcxproj]
d:\work\tobuild\osqp\src\util.c(332): warning C4996: 'fopen': This function or variable may be unsafe. Consider using
fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [D:\Work\ToBuild\os
qp\build\osqp.vcxproj]
d:\work\tobuild\osqp\src\util.c(397): warning C4996: 'fopen': This function or variable may be unsafe. Consider using
fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [D:\Work\ToBuild\os
qp\build\osqp.vcxproj]


"D:\Work\ToBuild\osqp\build\ALL_BUILD.vcxproj" (cible par défaut) (1) ->
"D:\Work\ToBuild\osqp\build\osqpstatic.vcxproj" (cible par défaut) (8) ->
d:\work\tobuild\osqp\src\osqp.c(454): warning C4244: 'fonction' : conversion de 'c_int' en 'double', perte possible d
e données [D:\Work\ToBuild\osqp\build\osqpstatic.vcxproj]
d:\work\tobuild\osqp\src\util.c(332): warning C4996: 'fopen': This function or variable may be unsafe. Consider using
fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [D:\Work\ToBuild\os
qp\build\osqpstatic.vcxproj]
d:\work\tobuild\osqp\src\util.c(397): warning C4996: 'fopen': This function or variable may be unsafe. Consider using
fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [D:\Work\ToBuild\os
qp\build\osqpstatic.vcxproj]


"D:\Work\ToBuild\osqp\build\ALL_BUILD.vcxproj" (cible par défaut) (1) ->
"D:\Work\ToBuild\osqp\build\osqp_demo.vcxproj" (cible par défaut) (7) ->
(Link cible) ->
LINK : fatal error LNK1104: impossible d'ouvrir le fichier 'out\Debug\osqp.lib' [D:\Work\ToBuild\osqp\build\osqp_demo
.vcxproj]

20 Avertissement(s)
1 Erreur(s)

Goran Banjac

unread,
Nov 16, 2018, 9:40:38 AM11/16/18
to OSQP
I am sorry, but I cannot reproduce the error on my machine. It generates osqp_demo.exe the first time I build the project.

remi.de...@gmail.com

unread,
Nov 16, 2018, 10:27:41 AM11/16/18
to OSQP
it does not matter. The important thing is that I have the dll file and the lib file. :)

If I have to build twice I'll do it. When I have time I will see why it does not work the first time.

Reply all
Reply to author
Forward
0 new messages