Thread: compilation problem C::B minigw gcc gnu

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    10

    compilation problem C::B minigw gcc gnu

    Hello,

    I have errors compilation with my program, I think mistakes don't come from code but from the compiler.
    here are the errors :
    Code:
    ||=== Build: Debug in crypto (compiler: GNU GCC Compiler) ===|C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `__imp_GetDeviceCaps'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `__imp_CreateCompatibleBitmap'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `__imp_GetObjectW'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `__imp_GetDIBits'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `__imp_DeleteObject'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `inflate'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflate'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `inflateEnd'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflateEnd'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `inflateEnd'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflateEnd'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `inflateInit_'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflateInit_'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflate'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `zError'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflate'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `zError'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `deflateInit_'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `inflate'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `zError'|
    C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\9.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c|| undefined reference to `inflateInit_'|
    ||error: ld returned 1 exit status|
    ||=== Build failed: 22 error(s), 0 warning(s) (0 minute(s), 45 second(s)) ===|
    here is code :
    Code:
    #include <iostream>#include <windows.h>
    #include <string>
    #include <ec.h>
    #include <obj_mac.h>
    //#include <err.h>
    #include <bn.h>
    using namespace std;
    
    
    
    
    int main()
    {
        EC_KEY * key;
    
    
       if(NULL == (key = EC_KEY_new_by_curve_name(NID_secp256k1)))
       {
           std::cout << "erreur" << std::endl;
       }
    
    
    
    
        if(1 != EC_KEY_generate_key(key))
            {
               std::cout << "erreur" << std::endl;
    
    
            }
    
    
           BIGNUM * prv = NULL;
           EC_POINT * pub = NULL;
    
    
    
    
       if(1 != EC_KEY_set_private_key(key, prv))
       {
          std::cout << "erreur" << std::endl;
    
    
       }
       if(1 != EC_KEY_set_public_key(key, pub))
       {
           std::cout << "erreur" << std::endl;
    
    
       }
    
    
    
    
    
    
    }
    someone would how to solve the problem? help me please
    Last edited by inteligent; 12-29-2019 at 02:15 PM.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Post the build log. You should know the above are linker errors. And that means you are not linking to the correct libraries or not in the correct order.

    Likely need to link to "crypto" library

    Edit: If you tried to build the "crypto" library yourself you did it wrong.
    If you are using the "crypto"/"openssl" library as source code you are doing it wrong.

    Tim S.
    Last edited by stahta01; 12-29-2019 at 02:41 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    Where can we link to the "crypto" libraries on C :: B ? Sorry for the question I'm a beginner.

    ps : I downloaded openssl from sourceforge.net

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by inteligent View Post
    Where can we link to the "crypto" libraries on C :: B ? Sorry for the question I'm a beginner.

    ps : I downloaded openssl from sourceforge.net
    Since, you failed to install openssl using pacman, I have no idea on how to help you without a full build log.
    I suggest reading the CB FAQs and learning how to use MSys2 correctly.

    FAQ-Compiling (general) - CodeBlocks

    Tim S.
    Last edited by stahta01; 12-29-2019 at 07:37 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    MSys2 commands used by me.

    Command to install mingw 64 bit openssl
    Code:
    pacman -S mingw-w64-x86_64-openssl
    Command to confirm mingw 64 bit openssl is installed
    Code:
    pacman -Qs mingw-w64-x86_64-openssl


    C::B projectSettings

    Compiler search directories
    Code:
    $(TARGET_COMPILER_DIR)include\openssl
    Linker search directories
    Code:
    $(TARGET_COMPILER_DIR)lib
    Link libraries
    Code:
    crypto
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  6. #6
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    Quote Originally Posted by stahta01 View Post
    Since, you failed to install openssl using pacman, I have no idea on how to help you without a full build log.

    Tim S.
    I did not install I did not install openssl on msys but from a link from sourceforge.net.So i will reinstall it from msys


    And here is log build :

    Code:
    -------------- Build: Debug in crypto (compiler: GNU GCC Compiler)---------------
    
    g++.exe -LC:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib -o bin\Debug\crypto.exe obj\Debug\main.o   C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libssl.a
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c:(.text+0xbdb): undefined reference to `__imp_GetDeviceCaps'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c:(.text+0xc08): undefined reference to `__imp_CreateCompatibleBitmap'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c:(.text+0xc1e): undefined reference to `__imp_GetObjectW'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c:(.text+0xce1): undefined reference to `__imp_GetDIBits'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(rand_win.o):rand_win.c:(.text+0xd70): undefined reference to `__imp_DeleteObject'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x59): undefined reference to `inflate'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xea): undefined reference to `deflate'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x13d): undefined reference to `inflateEnd'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x158): undefined reference to `deflateEnd'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x1c3): undefined reference to `inflateEnd'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x1cc): undefined reference to `deflateEnd'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x268): undefined reference to `inflateInit_'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x2d1): undefined reference to `deflateInit_'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x526): undefined reference to `deflate'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x5cf): undefined reference to `zError'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x7cc): undefined reference to `deflate'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x84f): undefined reference to `zError'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x8de): undefined reference to `deflateInit_'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x9a3): undefined reference to `inflate'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xa11): undefined reference to `zError'
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\openssl-1.0.2j-fips-x86_64\OpenSSL\lib\libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xa83): undefined reference to `inflateInit_'
    collect2.exe: error: ld returned 1 exit status
    Process terminated with status 1 (0 minute(s), 28 second(s))
    22 error(s), 0 warning(s) (0 minute(s), 28 second(s))

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Build messages is not a full build log.
    FAQ-Compiling (errors) - CodeBlocks


    Why not do it the normal way and install the msys2 package?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    You can try linking to the "z" library if you wish to continue on your path of ignoring how msys2 is normally used.

    Edit: Likely need to link "gdi32" library, also.

    Edit2: Building the normal msys2 way I did not need to link to "gdi32" or "z" libraries.

    Tim S.
    Last edited by stahta01; 12-30-2019 at 10:44 AM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  9. #9
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    I install openssl in msys2 but I have a problem when I enter this command line in the cmd:
    Code:
    (TARGET_COMPILER_DIR) include \ openssl
    here is problem :
    Code:
    bash: syntax error near the unexpected symbol "include \ openssl"
    My question is :
    why is there a problem ? While the path of "include/openssl" exist and it is right.

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    NOTE: Typing in CB Project setting on the command line will almost always error out!

    Tim S.
    Last edited by stahta01; 12-30-2019 at 12:49 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  11. #11
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    so where should I grab it. In C: B -> project -> build options -> Linker settings or compiler settings or other things

  12. #12
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    I think have find the solution to my last question, so my question is rather on the folder or file "crypto" "link libraries" .
    in which folder it is ?
    Last edited by inteligent; 12-30-2019 at 02:49 PM.

  13. #13
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    This is a web link please follow it and read the information!
    FAQ-Compiling (general) - CodeBlocks

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  14. #14
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by stahta01 View Post
    This is a web link please follow it and read the information!
    FAQ-Compiling (general) - CodeBlocks

    Tim S.
    For your project :
    - Right click on the project then select Build options
    - Select the directories tab
    - Add the required paths for compiler and linker.
    - Add your specific libraries in the linker tab.
    - Pay attention to project settings and target settings.
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  15. #15
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    J'ai suivi la méthode du site web " CodeBlocks FAQ-compilation C :: B" mais j'ai toujours des erreurs et elles sont ici:

    Code:
    || === Build: Debug in crypto (compilateur: GNU GCC Compiler) === | 
    ld.exe || ne trouve pas C: \ openssl-master \ crypto: autorisation refusée | 
    || erreur: ld a renvoyé 1 état de sortie | 
    || === Échec de la construction: 2 erreur (s), 0 avertissement (s) (0 minute (s), 5 seconde (s)) === |
    "lib" and "include" are in the folder C:\msys64\mingw64\x86_64-w64-mingw32 while I must go search the folder "crypto" in code source of openssl than I'have Download.
    Last edited by inteligent; 12-30-2019 at 08:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 08-21-2012, 12:35 AM
  2. Need help installing MiniGW
    By kelso135 in forum C Programming
    Replies: 5
    Last Post: 09-10-2005, 07:49 AM
  3. need help downloading and installing MiniGW compiler
    By kelso135 in forum C Programming
    Replies: 3
    Last Post: 09-01-2005, 04:17 PM
  4. Compilation problem
    By Armatura in forum C++ Programming
    Replies: 5
    Last Post: 11-12-2003, 12:42 AM
  5. compilation problem
    By Abdi in forum C Programming
    Replies: 3
    Last Post: 05-28-2002, 10:59 AM

Tags for this Thread