Menu

Proper method for linking a library file...

Eric Davis
2009-01-19
2012-09-26
  • Eric Davis

    Eric Davis - 2009-01-19

    Project/Parameters/Add Library or Object:

    "../Dev-Cpp/New Folder/lib/libcomctl32.a"

    Correct?

     
    • cpns

      cpns - 2009-01-20

      Well, it shows a sucessful compilation, so why are you worried!?

      Why have you changes the default library path to "C:/Dev-Cpp/New Folder/lib"? It should not need changing, and it should not contain spaces.

      Because "../Dev-Cpp/New Folder/lib/libcomctl32.a" is a relative path, it will only work if your project folder is correctly located in relation to the Dev-Cpp folder. It is just a bad idea.

      When you explicitly link a file, it must exist, even if your project references nothing from it, so it is a bad idea to link general OS libraries like that. Because you ill-advisedly modified the default library path, the -lcomctl32 option will link "C:/Dev-Cpp/New Folder/lib/libcomctl32.a" in any case, the explicit link is unnecessary and should be removed.

      Since the code linked I have no idea why you are asking the question, or why you chose to screw with default library paths.

      Clifford

       
    • cpns

      cpns - 2009-01-19

      You can specify an absolute or relative path. Your relative path will only work if your project is is a first-level subfolder of c:\ (assuming you installed Dev-C++ in c:\dev-cpp).

      Avoid paths with spaces.

      I would also avoid adding third-party libraries to the Dev-C++ installation folder, unless it was installed by a devpak.

      Why are you adding this file in any case? It already exists in c:\dev-cpp\lib. It is part of teh Win32 API.

      If the path to libcomctl32.a is added to the library search list (c:\dev-cpp\lib already is), then just -lcomctl32 will do. Post the build log, that will tell us if you have it set up correctly or not.

      Clifford

       
    • Eric Davis

      Eric Davis - 2009-01-19

      Compiler: Default compiler
      Building Makefile: "C:\Programing\Makefile.win"
      Executing make...
      make.exe -f "C:\Programing\Makefile.win" all
      windres.exe -i Project1_private.rc --input-format=rc -o Project1_private.res -O coff

      g++.exe main.o Project1_private.res -o "Project1.exe" -L"C:/Dev-Cpp/New Folder/lib" -L"C:/Dev-Cpp/New Folder/lib" -mwindows "../Dev-Cpp/New Folder/lib/libcomctl32.a" -lcomctl32

      Execution terminated
      Compilation successful

       

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.