Andy's Workshop Forums

General Category => stm32plus C++ library => Topic started by: pratipm on January 30, 2015, 09:10:34 pm

Title: How best to duplicate an example project in eclipse/CDT
Post by: pratipm on January 30, 2015, 09:10:34 pm
What is the best way to duplicate an eclipse/CDT project? I tried to duplicate an existing project in the example directory by right click/edit-copy/edit-paste followed by renaming everything about the original project/files both at the Project Explorer level as well as in the Project properties. Everything up to build works fine, but GDB always complains about missing original source file. I used grep on every file in my project directory and could not find a single instance of that original .cpp file/directory name. Not sure where GDB is getting the reference to the file from the old project.
I understand this is not really stm32plus issue, but any help will be greatly appreciated.
Thanks in advance.

-Pratip
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: Andy Brown on January 31, 2015, 01:51:54 am
Hi Pratip, I do this all the time to get a project up and running quickly:



That's it, all done.
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: pratipm on January 31, 2015, 06:11:54 am
Thanks a ton. That works!
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: mariusl on February 01, 2015, 01:21:46 am
Hi Andy
I did as you described above. Everything compiles correctly but the linker gives an error that it cannot find the library.
I moved the library to under my workspace and changed the paths to point there. All the other tools do find the lib except for the linker.
Any ideas on what I am doing wrong

I use Eclipse Kepler on Ubuntu 14.01
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: Andy Brown on February 01, 2015, 05:06:54 am
I'm assuming that the library has actually been built first before the example for the MCU that you're compiling against - each project (including the library) has multiple MCU targets.

That being the case it's probably the workspace-relative paths that I've configured in Eclipse. For example, on an F4 build the examples linker search path is:

"${workspace_loc:/stm32plus/Debug_f4_168}"

That means you must have a project called 'stm32plus' (the library) in your workspace and it has to have been built for the F4 which will have produced output in the Debug_f4_168 directory. Does this match your workspace?
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: mariusl on February 01, 2015, 10:32:30 am
Hi Andy
I did go through all the settings and changed the paths to the correct location.
If I cut and paste the error into a terminal and use it in a cd command, it does find the directory and if I do a "less" of the path and file reported by the error, it does find the file.

Do I have to include the extension on the lib file name. The .a I mean?

I have a workspace called workspaceSTM32 and I copied the button example into that. The lib directory is in the workspace.
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: pratipm on February 01, 2015, 11:39:11 am
I had the same problem of missing libstm32 from the linker, but then found out that my build configuration in the copied project was not set right.
But I still do have the same problem as before, gdb still trying to look for wrong .cpp file, from the project that I copied from.

No source file named /home/pratip/stm32plus-master/examples/usart_send_sync/usart_send_sync.cpp.

monitor halt
continue
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Program received signal SIGINT, Interrupt.
main () at ../usart_receive_sync.cpp:88
88     test.run();

Strangely, can't find any such reference in my project directory.
~/stm32plus-master/MyProject/ESP8266Test > find . -type f | xargs grep usart_send_sync
returns nothing

Still trying to tinker with eclipse/gdb settings if I can find something.
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: pratipm on February 01, 2015, 11:48:01 am
Just noticed in the GDB output that GDB is trying to run wrong executable. It so happened that I did forget to perform one step, deleting the original .cpp file and copy my own. Corrected that, refreshed the project and did a clean rebuild, but still same error:

No source file named /home/pratip/stm32plus-master/examples/usart_send_sync/usart_send_sync.cpp.

monitor halt
continue
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Program received signal SIGINT, Interrupt.
main () at ../ESP8266Test.cpp:145
145      test.run();
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: mariusl on February 02, 2015, 03:17:45 am
Hi Andy
This is what I did:
1) I did a new pull
2) I compiles a new library
3) I installed to the default /user/local directory
4) I changed the path and lib information for the linker

still the same problem


12:11:32 **** Incremental Build of configuration Debug_f4_168 for project button ****
make all
Building target: button.elf
Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -Werror -Wall -Wextra  -g3 -T /home/badev/embed/workspaceSTM32/button/system/f4/Linker.ld -Xlinker --gc-sections -L/usr/local/arm-none-eabi/lib/stm32plus-040000 -Wl,-Map,"button.map" -Wl,-wrap,__aeabi_unwind_cpp_pr0 -Wl,-wrap,__aeabi_unwind_cpp_pr1 -Wl,-wrap,__aeabi_unwind_cpp_pr2 -o "button.elf"  ./system/f4/Startup.o ./system/f4/System.o  ./system/LibraryHacks.o  ./button.o   -l/usr/local/arm-none-eabi/lib/stm32plus-040000/libstm32plus-debug-f407-8000000.a
/home/badev/embed/gcc-arm-none-eabi-4_8-2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld: cannot find -l/usr/local/arm-none-eabi/lib/stm32plus-040000/libstm32plus-debug-f407-8000000.a
collect2: error: ld returned 1 exit status
make: *** [button.elf] Error 1


I am sure this is an Eclipse issue but I thought by using absolute path information it could not fail.

Thanks for your help with this.
Can I send any project files or something else that might help?
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: mariusl on February 02, 2015, 06:28:02 am
Ok I found the include problem. One should specify the library name with a ":" in the front if you want to include the name as it is. I.E. :/workspace/lib/..... If not the linker will want to find a library without the lib in in front of the name and also no extension to the file.

Now to get the debugger to recognise the .elf file as valid :(
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: mariusl on February 02, 2015, 07:05:31 am
I did not manage to get the debugger working as Andy describes but I used this tutorial to get going.

http://vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/ (http://vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/)

I have not done a lot of debugging so I don't know how good it is but the button example works well with break points.
Title: Re: How best to duplicate an example project in eclipse/CDT
Post by: Andy Brown on February 02, 2015, 02:27:41 pm
Quote from: mariusl on February 02, 2015, 07:05:31 am
I did not manage to get the debugger working as Andy describes but I used this tutorial to get going.

http://vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/ (http://vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/)

I have not done a lot of debugging so I don't know how good it is but the button example works well with break points.


Good to hear that you've got debugging working and that you can link OK. Once you're up and running with breakpoints working you're home and dry as far as debugging goes. Please let me know if you need any more assistance.