Menu

Distributing C++ program? Statically linking?

2009-02-04
2012-09-26
  • Erik Abrahamsson

    Hi everyone,

    I would have searched the forums, if there was a way. But I've looked through the first couple hundred threads, and found no answer to my question. So here I go!

    I want to compile a small and simple Windows (C++) program, ship it to my friends and family. Just the Program.exe, nothing more. And I want it to work. Without "The application failed to initialize properly (0xc0150002)".

    How do I do that? Currently my program relies on msvcrt.dll (and perhaps some more of those C++ runtime libraries). Is it possible to do that? I know other people can...

    Of course my program works perfectly on my machines , as I have both Dev-C++ and MS VC installed (not on the Vista machine, but on my two XP's). But most people don't, for some reason...

    I feel like a total n00b, as the kids say, but I've never had these kind of problems in Fortran...

    /Erik

     
    • cpns

      cpns - 2009-02-04

      > I would have searched the forums, if there was a way.

      There is. Forums->Search in the menu in the orange band at the top of the page! That said, the search does suck big-time.

      > And I want it to work. Without "The application failed to initialize properly (0xc0150002)".

      You seem to be implying that that happens to everyone. Why do you think you are getting that message?

      > Currently my program relies on msvcrt.dll

      MSVCRT.DLL is installed with the Windows OS. This has been true since later releases of Windows 95! If you application was missing a DLL, that is not teh message you would get in any case. It would at least tell you what DLL it was expecting.

      In short, the problem is not what you think it is, so you will have to give more information.

      1) Is the program question built with VC++ or Dev-C++?

      2) Which version of either are you using?

      3) As ever post your build log.

      4) Google "The application failed to initialize properly" for a whole raft of more plausible reasons why you might get this message.

      5) If you are using VC++ Express Edition, you will need to install the VC++ redistributable on any machine that does not already have it, or the same version or later VC++ installed. http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en

      Clifford

       
      • Erik Abrahamsson

        Hi Clifford,

        Thanks for the reply!

        I didn't actually know about the search function! Been looking for it at some other Sourceforge forums, but never found it. Thanks!

        And I am have no idea why I get that message. The only reason I've found is that it's a problem from compiling with VC++ Express, and that C++ runtime libraries are missing. But I am, of course, using Dev-C++ (that's why I ask here). It could also be a problem with SP1 on XP. It seems to work on some computers, but not all.
        -Why? I have no idea.

        As for the missing information:
        1) I am using Dev-C++.

        2) Version 4.9.9.2.

        3) Build log:
        Compiler: Default compiler
        Building Makefile: "C:\Dev-Cpp\Makefile.win"
        Executing make...
        make.exe -f "C:\Dev-Cpp\Makefile.win" all
        g++.exe BioVEC.o BioVEC_private.res -o "BioVEC.exe" -L"C:/Dev-Cpp/lib" -lopenglut -lglu32 -lopengl32 -lwinmm -lgdi32 -ldevil -lilu -lilut

        Execution terminated
        Compilation successful

        My guess is that this is where the problem is. That I'm not linking properly. In VC++ there is the "Debug" and "Release" modes. Is there anything similar in Dev-C++? I've added some optimizations to the compiler, is that hidden in the *_private.res term in the command line?

        Or is it just the one machine (the one where it has to work, but won't) that actually is the problem? Perhaps I should take a closer look at that machine... And see if I can test it on some more (it works on three out of four machines now, but the three working ones are all mine, and I do take care of my computers).

        Well, that's all. Thanks a lot for your help and your interest. Any further comments would be very helpful!

        /Erik

         
        • Erik Abrahamsson

          Oh, I chose Rebuild All and got the following compile log:

          Compiler: Default compiler
          Building Makefile: "C:\Dev-Cpp\Makefile.win"
          Executing make clean
          rm -f BioVEC.o BioVEC_private.res BioVEC.exe

          g++.exe -c BioVEC.cpp -o BioVEC.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -DOPENGLUT_STATIC -fexpensive-optimizations -O2

          windres.exe -i BioVEC_private.rc --input-format=rc -o BioVEC_private.res -O coff

          g++.exe BioVEC.o BioVEC_private.res -o "BioVEC.exe" -L"C:/Dev-Cpp/lib" -lopenglut -lglu32 -lopengl32 -lwinmm -lgdi32 -ldevil -lilu -lilut

          Execution terminated
          Compilation successful

          So now I know where the optimizations are entered.

          /E

           
    • cpns

      cpns - 2009-02-05

      If something weird happens, loose the weird settings. Certainly remove the -fexpensive-optimizations -O2 ("Premature optimisation is the root of all evil" - Donald Knuth)

      > In VC++ there is the "Debug" and "Release" modes. Is there anything similar in Dev-C++?

      No , unfortunately not.

      > -ldevil -lilu -lilut
      What are these libraries? Are they statically linked?

      > My guess is that this is where the problem is. That I'm not linking properly.

      If the linker ran without error, it is by definition 'linked properly'. However it may be linking DLL export libraries for which the DLLs don't exist on other machines, but as I said, I would expect it to tell you which DLL.

      > Building Makefile: "C:\Dev-Cpp\Makefile.win"

      Don't build or create your project there. For starters 'polluting' the installation is a bad idea, but also there is a strange bug in Dev-C++ that sometimes (not always) caused builds in c:\dev-cpp or subfolders thereof to fail.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.