Page 1 of 1

Specify shared library path to GDB

Posted: Thu Sep 13, 2012 7:31 pm
by mattday
I have a workspace in which the active project links against several of the other projects, one of which is a DLL. The only way I have successfully managed to use the debugger is by copying the DLL to the same directory as the executable. (Note: It should be possible to automate this as a post-build command, but this is not really what I want). If I don't copy the DLL, I get a message box: Debugger exited with the following error string: "During startup program exited with code 0xc0000135".

It seems as though it should be possible to point GDB to my DLL. Something similar seems to happen with the wxWidgets DLL (because this is not in the system path) but from the debugger output I can't see exactly how. I have not had any success playing with the settings - e.g. I tried adding 'set solib-search-path <my_dll_path>' under debugger startup commands, among other things. Ideally, perhaps CodeLite could do what I want automatically for any library paths given to the linker for the active project. Anyhow, for now I would appreciate any pointers on how to let GDB know where this DLL is located.

Thanks, Matt

CodeLite: v4.0.5589 with GDB 7.4 (installed as binary package with wxWidgets)
OS: Windows XP Pro / Windows XP Pro x64

Re: Specify shared library path to GDB

Posted: Thu Sep 13, 2012 8:24 pm
by eranif
There are several ways to fix this, you can alter the PATH environment variable in the project level ,workspace level or globally

To modify it on the project level (IMO, the recommended way):
right click on your project: Settings -> Common Settings -> Environment -> Additional environment variables
and add the following:

Code: Select all

PATH=\path\to\my\dll;$(PATH)
Or you can do it globally (i.e. it affects all workspaces / projects):

Settings -> Environment Variables -> Default
( I am assuming here that you did not create an additional environment set and you are using the 'Default' set)
Add this line at the end:

Code: Select all

PATH=\path\to\my\dll;$(PATH)
Eran

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 5:08 pm
by mattday
Many thanks for this. Although, perhaps the syntax is not quite right, because it does not have the desired effect (i.e. the DLL is still not found).

If I place the DLL together with the executable, and just leave the environment variables box empty, it will launch. If I then add the following to the environment variables box (leaving the DLL with the executable), it will fail as before.

Code: Select all

PATH=$(PATH)
So something is happening with this setting that is not at all obvious to me. I tried clearing the path completely to see what happens, but that gives the message box: Failed to locate gdb
i.e:

Code: Select all

PATH=""
As a side note, I updated to the latest CodeLite release, and it no longer shows a message box indicating the 0xc0000135 error code. The debugger just exits immediately now. However, looking at the output the problem is the same.

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 5:44 pm
by eranif
mattday wrote:Many thanks for this. Although, perhaps the syntax is not quite right, because it does not have the desired effect (i.e. the DLL is still not found).
It is correct.
Can we see what did you write in the environment variables that failed?
mattday wrote:So something is happening with this setting that is not at all obvious to me. I tried clearing the path completely to see what happens, but that gives the message box: Failed to locate gdb
Do not clear PATH, it will probably fail perform almost everything. Whenever you modify PATH from within codelite, make sure you prepend or append your path to the current content

But like I said before, if it failed - show us what you placed in the PATH that failed, otherwise I wont be able to assist you

Eran

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 6:03 pm
by mattday
Initially, I tried exactly as you advised. When a relative path didn't seem to work, I tried a fully specified path. So it looked like this:

Code: Select all

PATH=D:\somefolder\myproject\mydll\debug;$(PATH)
I tried the following, only to try and figure out what was happening, because if I understand correctly, it should not change anything:

Code: Select all

PATH=$(PATH)
However, it does have some effect. The library loads from the same location as the executable without it, but it does not with it.

Many thanks for you swift assistance Eran - I appreciate it.

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 6:18 pm
by eranif
mattday wrote:Initially, I tried exactly as you advised. When a relative path didn't seem to work, I tried a fully specified path. So it looked like this:
Where did you place this line? in the global settings (Settings -> Environment variables ) or in the project level?

Eran

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 6:20 pm
by mattday
For the active project

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 6:31 pm
by mattday
Just tried adding to the global settings, and that works! However, I would rather not do that because this copy of the DLL code was checked out as a SVN external as part of this application.

Re: Specify shared library path to GDB

Posted: Fri Sep 14, 2012 6:44 pm
by eranif
mattday wrote:Just tried adding to the global settings, and that works!
In this case this sounds like a bug to me
mattday wrote: this copy of the DLL code was checked out as a SVN external as part of this application
I understand. To workaround this (i.e. change the PATH only for the current project) you can use the "Environment Variables Set" feature of codelite:

- Create a new environment variable set from: Settings -> Environment variables -> New Set...
- Give this set a name
- Copy the content of the "Default" set to the new set
- Add the PATH changes to the newly created set
- Click OK and close the environment variables dialog
- Open the project settings dialog -> "Common Settings -> Environment -> Environment variables set to use" and select the new set name
- Click OK and close the project settings dialog.

To confirm that you did it right, at the bottom right of codelite's status bar, you should see a little message that says:
Env: <set name>, Dbg: Default

Now whenever you load this project the newly created environment variables set will be the active

Eran