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

MinGW cmake error #5

Open
bolunfeng opened this issue Aug 1, 2019 · 7 comments
Open

MinGW cmake error #5

bolunfeng opened this issue Aug 1, 2019 · 7 comments

Comments

@bolunfeng
Copy link

hi:
I want to compile openssl-cmake on window7 platform.when I run this command:
D:\software\openssl-cmake>cmake -DCMAKE_INSTALL_PREFIX=D:\software\openssl-cmake -DCMAKE_BUILD_TYPE=debug -G "MinGW Makefiles" .

I get some error:

-- Detecting CXX compile features - done
-- OpenSSL version 1.1.1b
CMake Error at D:/software/gt_compress/3thparty/win_lib/CMake/share/cmake-3.9/Modules/CheckIncludeFile.cmake:46 (configure_file):
configure_file attempted to configure a file:
D:/software/openssl-cmake/CMakeFiles/CMakeTmp/CheckIncludeFile.c into a
source directory.
Call Stack (most recent call first):
D:/software/gt_compress/3thparty/win_lib/CMake/share/cmake-3.9/Modules/CheckTypeSize.cmake:223 (check_include_file)
CMakeLists.txt:144 (check_type_size)

I need your help.thanks.

@janbar
Copy link
Owner

janbar commented Aug 1, 2019

Hi, to build native libs you should prefer to use the default generator for ms-windows like below:

mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=D:\software\openssl-cmake ../
cmake --build . --config Debug --target install

To compile 32 bits binaries you have to remove the option "CMAKE_GENERATOR_PLATFORM".

Else I never tried using make of mingw on windows. todo.

@janbar
Copy link
Owner

janbar commented Aug 1, 2019

Regarding the message returned by CMake, it seems you CANNOT build the project in the source folder. So probably you have to MKDIR the folder build, then CD build, and finally launch the build.

@bolunfeng
Copy link
Author

thanks. I have mkdir a folder.then I run this command:

  1. openssl-cmake\build>cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=D:\software\install -G "MinGW Makefiles" ..\
  2. then,make:
    this step get a error:
    [ 99%] Building C object apps/CMakeFiles/openssl.dir/spkac.c.obj
    [ 99%] Building C object apps/CMakeFiles/openssl.dir/storeutl.c.obj
    [100%] Building C object apps/CMakeFiles/openssl.dir/srp.c.obj
    [100%] Building C object apps/CMakeFiles/openssl.dir/ts.c.obj
    [100%] Building C object apps/CMakeFiles/openssl.dir/verify.c.obj
    [100%] Building C object apps/CMakeFiles/openssl.dir/version.c.obj
    [100%] Building C object apps/CMakeFiles/openssl.dir/x509.c.obj
    [100%] Building C object apps/CMakeFiles/openssl.dir/win32_init.c.obj
    [100%] Linking C executable openssl.exe
    ../crypto/libcrypto.a(async_win.c.obj):async_win.c:(.text+0x7f): undefined reference to GetCurrentFiber' ../crypto/libcrypto.a(async_win.c.obj):async_win.c:(.text+0x7f): undefined reference to GetCurrentFiber'
    collect2.exe: error: ld returned 1 exit status
    apps\CMakeFiles\openssl.dir\build.make:1530: recipe for target 'apps/openssl.exe' failed
    make[2]: *** [apps/openssl.exe] Error 1
    CMakeFiles\Makefile2:195: recipe for target 'apps/CMakeFiles/openssl.dir/all' failed
    make[1]: *** [apps/CMakeFiles/openssl.dir/all] Error 2
    Makefile:150: recipe for target 'all' failed
    make: *** [all] Error 2

@bolunfeng
Copy link
Author

I get this error:
[100%] Building C object apps/CMakeFiles/openssl.dir/srp.c.obj
[100%] Building C object apps/CMakeFiles/openssl.dir/ts.c.obj
[100%] Building C object apps/CMakeFiles/openssl.dir/verify.c.obj
[100%] Building C object apps/CMakeFiles/openssl.dir/version.c.obj
[100%] Building C object apps/CMakeFiles/openssl.dir/x509.c.obj
[100%] Building C object apps/CMakeFiles/openssl.dir/win32_init.c.obj
[100%] Linking C executable openssl.exe
../crypto/libcrypto.a(b_addr.c.obj): In function addr_strings': D:/software/openssl-cmake/crypto/bio/b_addr.c:204: undefined reference to getnameinfo'
../crypto/libcrypto.a(b_addr.c.obj): In function BIO_ADDRINFO_free': D:/software/openssl-cmake/crypto/bio/b_addr.c:426: undefined reference to freeaddrinfo'
../crypto/libcrypto.a(b_addr.c.obj): In function BIO_lookup_ex': D:/software/openssl-cmake/crypto/bio/b_addr.c:693: undefined reference to getaddrinfo'
../crypto/libcrypto.a(b_addr.c.obj): In function addr_strings': D:/software/openssl-cmake/crypto/bio/b_addr.c:204: undefined reference to getnameinfo'
../crypto/libcrypto.a(b_addr.c.obj): In function BIO_ADDRINFO_free': D:/software/openssl-cmake/crypto/bio/b_addr.c:426: undefined reference to freeaddrinfo'
../crypto/libcrypto.a(b_addr.c.obj): In function BIO_lookup_ex': D:/software/openssl-cmake/crypto/bio/b_addr.c:693: undefined reference to getaddrinfo'
collect2.exe: error: ld returned 1 exit status
apps\CMakeFiles\openssl.dir\build.make:1530: recipe for target 'apps/openssl.exe' failed
make[2]: *** [apps/openssl.exe] Error 1
CMakeFiles\Makefile2:195: recipe for target 'apps/CMakeFiles/openssl.dir/all' failed
make[1]: *** [apps/CMakeFiles/openssl.dir/all] Error 2
Makefile:150: recipe for target 'all' failed
make: *** [all] Error 2

how can I fix it?

@janbar
Copy link
Owner

janbar commented Aug 2, 2019

You tried to build with a windows sdk to old (xp), and not supported by openssl. So you have to upgrade your sdk, getting the latest visual studio community edition. An other solution is to define WINVER=0x501 as follow if your are sure using a sdk compatible with win2000 platform:

cmake .... -DWINVER=0x501 ...

but not guarantee :). A better way should be to upgrade your windows os to the latest (10) which is a bit more comptable with POSIX.

@bolunfeng
Copy link
Author

Tanks for your patience!I think I have found the error.
This project can be build successfully in release mode.
cmake -G "CodeBlocks - MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
then,make .

However,in debug mode,cmake -G "CodeBlocks - MinGW Makefiles" -DCMAKE_BUILD_TYPE=debug -DBUILD_SHARED_LIBS=ON ..\ ,I get the error:

@bolunfeng
Copy link
Author

E:\software\openssl-cmake\crypto\threads_win.c: In function 'CRYPTO_atomic_add':
E:\software\openssl-cmake\crypto\threads_win.c:154:5: warning: passing argument 1 of 'InterlockedExchangeAdd' from incompatible pointer type [enabled by default]
*ret = InterlockedExchangeAdd(val, amount) + amount;
^
In file included from E:/software/gt_compress/3thparty/win_lib/MinGW/i686-w64-mingw32/include/winbase.h:22:0,
from E:/software/gt_compress/3thparty/win_lib/MinGW/i686-w64-mingw32/include/windows.h:70,
from E:\software\openssl-cmake\crypto\threads_win.c:11:
E:/software/gt_compress/3thparty/win_lib/MinGW/i686-w64-mingw32/include/interlockedapi.h:38:37: note: expected 'volatile LONG *' but argument is of type 'int *'
__MINGW_INTRIN_INLINE LONG WINAPI InterlockedExchangeAdd(LONG volatile *Addend, LONG Value) {
^
[ 86%] Linking C shared library libcrypto.dll
CMakeFiles\crypto.dir/objects.a(async_win.c.obj): In function async_fibre_init_dispatcher': E:/software/openssl-cmake/crypto/async/arch/async_win.c:40: undefined reference to GetCurrentFiber'
collect2.exe: error: ld returned 1 exit status
crypto\CMakeFiles\crypto.dir\build.make:10229: recipe for target 'crypto/libcrypto.dll' failed
make[2]: *** [crypto/libcrypto.dll] Error 1
CMakeFiles\Makefile2:98: recipe for target 'crypto/CMakeFiles/crypto.dir/all' failed
make[1]: *** [crypto/CMakeFiles/crypto.dir/all] Error 2
Makefile:150: recipe for target 'all' failed
make: *** [all] Error 2

@bolunfeng bolunfeng reopened this Aug 5, 2019
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

2 participants