User forums > Using Code::Blocks

problems linking libraries [SOLVED]

(1/2) > >>

sspecter:
Hi all

Im having hard time linking library in my application.

Im making an Ogre application, and must call headers (.h) and libraries (.dll). I am putting the header directory in release/directories/compiler and the libraries directory in release/directories/linker.

My application is finding the headers but not the libraries. I tried to add all libraries in release/linker/link libraries with absolute, relative and no path but it didnt worked

The only thing that works is putting all DLLs in my application's dir (the app runs nicely). But I dont want do that.


 Maybe this is a newbie question but: How can I call/link a library from other directory?

mandrav:
Please describe your problem better.
What you said above gives no clue on what you 've done wrong. It only gives clues that you really did something wrong :)

To link a DLL, you need to link to its import library (libXYZ.a for gcc, XYZ.lib for msvc). Put the path with your libraries in "Project->Build options->Directories->Linker" and the libraries (without any path info) in "Project->Build options->Linker->Libraries".

If you still can't make it work, post here the full build log. To enable it, go to global compiler options "Other" page and set logging to full for the compiler you 're using. Then rebuild your project, copy the build log and paste it here...

yop:

--- Quote from: mandrav on February 11, 2006, 09:54:14 am ---To link a DLL, you need to link to its import library (libXYZ.a for gcc, XYZ.lib for msvc).
--- End quote ---
Or use the -rpath (see the man page) flag for gcc linker (don't know the equivelant for the m$ linker)

sspecter:
Sorry, my english is not that good, so ill try to be clearer.

this is what im doing:

- I put all .H files i need in \include directory
- I put all .DLLs and .A i need in \lib directory
- I add the "include" directory in Project->Build options->Release->Directories->Compiler
- I add the "lib" directory in Project->Build options->Release->Directories->Linker
- I tried everything at Project->Build options->Release->Linker->Link_Libraries. i've added all .A files, or all .DLL files, with or without patches. Dont matter what I do, I aways get the same result

What I get:

- The project is compiling, but windows give "Cannot find ogremain.dll" error window then executing. ogremain is one of the DLLs im trying to link.
- The project run without any error if I place all DLLs in the project root directory (same as the project source)

Obviously codeblocks isnt finding the DLLs. I dont have any clue why this is happening.


--- Quote from: mandrav on February 11, 2006, 09:54:14 am ---If you still can't make it work, post here the full build log. To enable it, go to global compiler options "Other" page and set logging to full for the compiler you 're using. Then rebuild your project, copy the build log and paste it here...

--- End quote ---

I enabled the log, but cant find it. were it is logged? I cant see the log anywere :(

Is there any Codeblock documentation, oficial or not? Ive searched through wiki but it didnt helped me much.

How i can use this -rpath?

mandrav:

--- Quote ---- I put all .DLLs and .A i need in \lib directory
--- End quote ---

So your problem is not with linking, but that it can't find the DLLs at runtime.

The DLL must be located either at the same directory with your EXE (preferred way), or in a system-wide path like \windows\system32 (not advised).

Navigation

[0] Message Index

[#] Next page

Go to full version