CppUTest environment on Eclipse and Kinetis Design Studio (KDS)

335 views
Skip to first unread message

Denis Dantas

unread,
Mar 15, 2016, 2:02:21 PM3/15/16
to cpputest
Hey there!

I'm trying to implement CppUTest at the company I work at. Here we use ARM Cortex M4 based NXP kinetis microcontrollers (FRDM-K64F, FRDM-K22F similar processors), which we develop using Kinetis Design Studio (KDS) 3.0.0, an Eclipse Mylyn based IDE, in Windows 7/8.

I followed the instructions in cpputest-3.7.1\platforms\Eclipse-Cygwin\README.md, built the project in my Eclipse Environment and ran the tests using the CppUTest Plugin. Next step I tried to create a C++ Cygwin as a testing environment. So I linked cpputest libraries (src and include files, with both CppUTest and CppuTestExt) to my project. When I tried to build the following simple test:

#include "CommandLineTestRunner.h"

int main(int ac, char** av)
{
    return CommandLineTestRunner::RunAllTests(ac, av);
}

I got the compile errors:

-make: *** [HelloWorldCpp.exe] Error 1 HelloWorldCpp C/C++ Problem

-recipe for target 'HelloWorldCpp.exe' failed makefile /HelloWorldCpp/Debug line 45 C/C++ Problem

-relocation truncated to fit: R_X86_64_PC32 against undefined symbol `CommandLineTestRunner::RunAllTests(int, char**)' HelloWorldCpp line 0 C/C++ Problem

-undefined reference to `CommandLineTestRunner::RunAllTests(int, char**)' HelloWorldCpp.cpp /HelloWorldCpp/src line 13 C/C++ Problem

I saw the the truncation error is related to linking address overflow for x86-64 bits machines, but I'm not sure what it might be going on.

Also I suppose I should set up a build for Cygwin target and another for my ARM Cortex device, is that right? If yes, will my arm compiler compile the CppUTest files? Any thoughts about a roadmap for setting up the tests environment for my scenario will be highly accepted.

Best Regards,

Denis

A. Robert S.

unread,
Mar 17, 2016, 3:17:28 AM3/17/16
to cpputest
Hi Denis,

That's definitely the weirdest error I've seen in a long time. It simply shouldn't be there.

Could you try to compile your simple test using a very simple, hand-made Makefile, instead of out of the Eclipse IDE?

About cross-compiling for the Arm Cortex device -- that is a more involved question. Let's get this problem fixed, first.

Robert

Denis Dantas

unread,
Mar 17, 2016, 1:16:22 PM3/17/16
to cpputest
Hello Robert,

alright I just built the same simple test code using a handmade makefile, based on cpputest/examples/Makefile. What else do you suggest me to do?

A. Robert S.

unread,
Mar 18, 2016, 1:31:29 AM3/18/16
to cpputest
Is eclipse using internal / external builder? If external, is it set to generate a Makefile?

My recommendation would be to set it up to use an external Makefile, possibly the one you wrote ;-).

Regards,

Robert

On Tuesday, March 15, 2016 at 7:02:21 PM UTC+1, Denis Dantas wrote:

A. Robert S.

unread,
Mar 18, 2016, 1:37:34 AM3/18/16
to cpputest
Also (as I've suggested in other answers) I would recommend when you set up your own project, not to combine building CppUTest and your own project. You won't need to rebuild CppUTest that often.

Rather, build yourself the CppUTest libraries (possibly with the debug option) and then just put the header and linker paths into your Makefile and just link the libraries.

You can keep a copy of CppUTest wherever is convenient for you; you can reduce that copy to just contain the headers and the libraries (possibly for two targets). That's what we do in a rather large project with 50+ developers using them.

Success,
Robert

Denis Dantas

unread,
Mar 18, 2016, 10:31:40 AM3/18/16
to cpputest
Hello Robert,

I've done exactly that. I I imported the code as a makefile project to eclipse to test it. On my embedded environment (kds), I added another build configuration to build the tests, linking the CppUTest project. So the tests are contained in my project and CppUTest is an independent project.

The thing is that although I'm able to build the project, eclipse is not linking resolving the CppUTest dependencies properly. It shows "unresolved inclusion" for my includes to the CppUTest header files. The Build Output Parser tool is supposed to do that, but could you give me any guidelines to how I should set up my makefile and eclipse for that?

Just out of curiosity, what sort of project with 50+ developers do you work with? 

BR

Denis

A. Robert S.

unread,
Mar 21, 2016, 2:56:54 AM3/21/16
to cpputest
Hi Denis,

I can't be sure of course, but what you describe sounds to me that you probably set up Eclipse to generate its own Makefile? Just a thought....

If you do Import...>C/C++>Existing Code as Makefile Project, then choose the directory that contains your Makefile, and select "Cygwin GCC" (this latter setting has no influence on the build process though), then there should be absolutely no difference in the result of running your Makefile.

Make sure the targets match up (all and clean being the default).

You can add targets such as check (to run your tests) or all_win and all_arm, clean_win, clean_arm etc to deal with your two targets. You can specify configurations in Eclpise such as "arm" and "win" to build those targets. Make sure your Makefile builds them into different directories, such as "arm" or "win" or (linker) confusion will result.

There should be NO build intelligence whatsoever in Eclipse. The need-to-know principle. All Eclipse needs to know is which target to run for what. In this kind of configuration, it is impossible for something not to work in Eclipse that does work with make.

The flip side of the coin is that you need to put all build information for both targets right into your Makefile.

Wishing you success,

Robert

On Tuesday, March 15, 2016 at 7:02:21 PM UTC+1, Denis Dantas wrote:

Denis Dantas

unread,
Mar 21, 2016, 8:06:59 AM3/21/16
to cpputest
Hello Robert,

I think I expressed myself wrong. I'm using my own makefile. What I did was: I created a new project on eclipse for my target processor, with release and debug builds. Then I added my makefile to the project and created another build for tests that uses my makefile. This is building. The thing is that eclipse interface does not open the includes from my make makefile, because it doesn't recognize them. For example, I #include "CppUTest\CommandLineTestRunner.h", but eclipse doesn't find the file and shows me error - although when I build the eclipse errors don't matter because my makefile is linking the files properly. So I would like to know a way that eclipse would find the dependencies of my tests, although I'm using my own makefile.

Also, I was happy with this configuration with two makefiles, because I'm not experienced writing my own makefiles. So eclipse is working with my target makefile, and I'm working on my tests makefile. Do you think it's more appropriate to have a single make file with different calls instead (make check, make arm, etc)? Why? I attached my makefile just in case you have any suggestions - it's a very simple one.
makefile

A. Robert S.

unread,
Mar 21, 2016, 8:22:38 AM3/21/16
to cpputest
...hmm. I'm no longer sure I understand how you are building, because if it is possible to use more than one Makefile, then I wasn't aware of that. Sorry... If that part actually works for you, there is no reason to change it. I had understood that it wouldn't build successfully from within Eclispse, which is what the errors you posted in the beginning definitely suggest ("don't know how to make.....").

Your problem seems to be with the Eclipse indexer and is relatively easy to solve. Just make sure to add the entire source tree to the Eclipse browser (Link Folder... > [Link...]) Then rerun the indexer and, with a little patience, Eclipse should stop putting those ugly red crosses all over the place. In particular, put a link to the CppUTest directory into your project tree (most probably the other sources are already in there).

I hope this helps,
Robert

Denis Dantas

unread,
Mar 21, 2016, 9:04:41 AM3/21/16
to cpputest
Hi Robert,

about building with different makefiles, once I created a different build configuration I went to Project Properties -> C/C++ Build -> Builder Settings. I unmarked "Generate Makefile automatically" and at Build Location I set the Build Directory to the directory of my own makefile. 

Could you be more specific about indexing the whole source tree? Which Link Folder do you mean? Is it in Project Properties?

BR

Denis

A. Robert S.

unread,
Mar 21, 2016, 9:38:58 AM3/21/16
to cpputest
(Your Project) > Properties > C/C++ General > Paths and Symbols > Source Location > [Link Folder...] > [x] Link to folder in the file system > Browse... (Your CppUTest Folder)

Possibly more of the same. The root folder will do.

(Eclipse hides stuff so well, compared to normal IDEs, they should pay me for those answers :-/)

Regards,
Robert

Denis Dantas

unread,
Mar 22, 2016, 8:54:19 AM3/22/16
to cpputest
Oh, thank you for all the attention Robert. Now my test environment is tidy. 

Best Regards,

Denis

A. Robert S.

unread,
Mar 24, 2016, 10:09:54 AM3/24/16
to cpputest
My pleasure :)
Reply all
Reply to author
Forward
0 new messages