DevIL icon indicating copy to clipboard operation
DevIL copied to clipboard

Link Error, Can't build Lib (Windows, VS2015, cmake)

Open dooglz opened this issue 8 years ago • 3 comments

In DevIL\include\IL\il.h the macro on line 58 checks for _IL_BUILD_LIBRARY, if not defined, DevIL.lib is linked. During the build process this causes Devil to try and link itself, as _IL_BUILD_LIBRARY is not defined in il.h (il_interal.h or something else is not included). Resulting in : "Error LNK1104 cannot open file 'DevIL.lib" This is with VS2015, building for Win10 x64, using cmake to generate the project.

dooglz avatar Aug 23 '16 13:08 dooglz

I've been working on the cmake build with the intention of pushing the changes back into the main repo.

The latest version is here: https://github.com/bcampbell/DevIL/tree/cmake_cleanup

I've not done much testing on visual studio, so if you can try it out I'd love to hear how you get on!

There's some relevant discussion in #29 - in particular, I think the link issue you encountered is covered there (and hopefully fixed in my fork)

bcampbell avatar Aug 23 '16 20:08 bcampbell

Thanks a lot for fixing this issue. This seems to compile properly for me, though I haven't pointed it to any of the other libraries (libtiff, libpng, etc.). I also tried to get CMake to create 64-bit projects, but that failed. This is what I get:

> cmake -G "Visual Studio 14 2015 Win64"
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of unsigned short
-- Check size of unsigned short - failed
-- Check size of unsigned int
-- Check size of unsigned int - failed
-- Check size of unsigned long
-- Check size of unsigned long - failed
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/TestBigEndian.cmake:51 (message):
  no suitable type found
Call Stack (most recent call first):
  CMakeLists.txt:18 (test_big_endian)

-- Configuring incomplete, errors occurred!

DentonW avatar Sep 03 '16 22:09 DentonW

I finally got around to trying it all out in visual studio, and got it compiling just fine for both 32bit and 64bit varieties (ie generators "Visual Studio 14 2015" and "Visual Studio 14 2015 Win64"). Both in release and debug. So I'm guessing that something I've changed since you tried it has fixed the issue :- )

I did encounter a slew of multiple-export link warnings due to the use of both .def files and __declspec() directives in the code, so I've disabled the .def files for now.

I also added a few more msvc details to README.cmake as I went.

Disclaimers:

  • I didn't try and include png/tiff/jpeg etc
  • I've not actually tried to run anything against the resulting IL.dll yet :- ) (next step would be to add some of the examples back into to the cmake build to start giving it a bit more of a workout)

(all in my cmake_cleanup branch, btw)

bcampbell avatar Nov 13 '16 02:11 bcampbell