how can I use eclipse to debug a libtool generated script?
Asked Answered
W

5

6

I have a large c++ project built with libtool. the problem is that eclipse will not run a libtool generated script, and I get a "Program is not a recognized executable." error message. how can I use eclipse debugger? I'm currently using kdevelop3 as an editor and debugging with insight.. which is horrible.

I could perhaps run the actual executable, thats in the ./libs of the project directory, but then I would have to manually set LD_LIBRARY_PATH and stuff like that... there must be a better way to so this.

any help would be appreciated!

Waldenses answered 16/11, 2011 at 13:22 Comment(1)
UPDATE: well, eventually I sqw no other option but setting all the environment variables myself (LD_LIBRARY_PATH and such) manually. this is of course a bad practice since these may change eventually, but i found no other way..Waldenses
A
2

Running a script instead of an executable is still unsupported in Eclipse, see this bug. Until the feature is introduced, you cannot debug a libtool-enabled project under Eclipse unless you keep something like a

    path/to/configure --disable-shared

separate configuration, thus relying on static linking only for debugging purposes.

To do that, you

  1. Open Project|Properties from the top menu

  2. Select Autotools|Configure Settings from the left menu of the window

  3. (Optionally) Create a new build configuration with a dedicated C/C++ Build|Builder Settings|Build location

  4. Under configure|Advanced, fill the "Additional command-line options" with --disable-shared

Adrianople answered 21/4, 2012 at 15:27 Comment(3)
Thanks, but than I still would have to specify the paths to the libraries myself, wouldn't I?Waldenses
No you wouldn't, since they are statically linked. There are other disadvantages, of course: each time you change the library, you need to recompile the executables; in addition, the executables are pretty bloated.Adrianople
Defeats one of the purposes of having libtool in the first place. +1 for a working solution though.Autacoid
W
2

You can work around it by running the actual executable instead of the libtool script. The executable will generally be found in .libs/. So in your debug configuration on the main tab set the value of C/C++ Application to something like .libs/my_application. Then all you'll need to do us update LD_LIBRARY_PATH within your debug configuration.

Go to the environment tab of your debug configuration and make a new environment variable called LD_LIBRARY_PATH. You'll want to append the .libs directory to the path. So the value should look like this: ${project_loc}/.libs:$LD_LIBRARY_PATH assuming your .libs folder is right inside of the project directory.

Wilmerwilmette answered 9/2, 2017 at 20:57 Comment(0)
A
1

You need to convince eclipse to start gdb like this:

$ libtool --mode=execute gdb <your-program>

See https://www.gnu.org/s/libtool/manual/html_node/Debugging-executables.html

Abbieabbot answered 9/12, 2011 at 14:8 Comment(1)
Yes, of course but how? iv'e tried many things including changing the debugger command line, but to no avail.Waldenses
B
1

I think one could write a little wrapper program to interpose an exec of 'sh libtool --mode execute' to run gdb. Call it 'gdb-libtool' and invoke that instead of gdb.

I am developing under both Windows and Linux so it's something I need for myself.

There are a few tricky bits, like getting the paths right at libtool and gdb invocation.. off to take a swat at that.

Cheers, Jerry.

Burleson answered 8/1, 2012 at 16:20 Comment(1)
Nope : Error creating session Cannot run program "gdb-libtool": Unknown reason –Waldenses
S
1

For the first point, you can disable intermediate libtool script by adding -no-install to LDFLAGS in your Makefile.am OR you can just run make install and debug from installed binary.

For the second point, you'll have to set and export your LD_LIBRARY_PATH before launching eclipse.

Scow answered 14/2, 2014 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.