Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Explicitly compiling more than one dependent files in Eclipse CDT(Need to explicitly add a file to the compilation command.)
Explicitly compiling more than one dependent files in Eclipse CDT [message #1774262] Thu, 12 October 2017 10:37 Go to next message
Hakan Bayindir is currently offline Hakan BayindirFriend
Messages: 11
Registered: January 2017
Location: Ankara, Turkey
Junior Member

Hello all,

I'm developing a software, which uses Easylogging++ as its logging library. The library was inside a single header before, but its developer divided it into two files (one .h and one .cc), so while compiling it, the .cc file needs to be included in the command line (relevent page is here).

I was able to build the code and work with eclipse while the code was a single header. Currently I cannot build the code since I cannot explicitly define the .cc file to be compiled alongside the file which contains the main().

Is there way to define auxiliary files while compiling the project?

Regards,

Hakan
Re: Explicitly compiling more than one dependent files in Eclipse CDT [message #1774335 is a reply to message #1774262] Fri, 13 October 2017 04:16 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Have you added .cc as a C++ file extent?

If not then
Window --> Preferences --> General --> Editors --> File Associations --> Add...
Add .cc
And set or add C++ Editor to .cc
index.php/fa/30995/0/


Assuming you are using a Managed Build, the .cc files should be in the src directory.
  • Attachment: FileAssoc.png
    (Size: 66.38KB, Downloaded 1353 times)
Re: Explicitly compiling more than one dependent files in Eclipse CDT [message #1774337 is a reply to message #1774335] Fri, 13 October 2017 06:01 Go to previous messageGo to next message
Hakan Bayindir is currently offline Hakan BayindirFriend
Messages: 11
Registered: January 2017
Location: Ankara, Turkey
Junior Member

Hi David,

Thanks for your answer. I've tried your suggestion, and the file is indeed built, however it's built as an independent file. What I need is to include the .cc file in the compilation command of the main application.

In other words, when I copy the file to the /src folder, following happens:

Building file: ../b3f/src/easylogging++.cc
Invoking: GCC C++ Compiler
g++ -std=c++0x -DELPP_THREAD_SAFE -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"b3f/src/easylogging++.d" -MT"b3f/src/easylogging++.o" -o "b3f/src/easylogging++.o" "../b3f/src/easylogging++.cc"
Finished building: ../b3f/src/easylogging++.cc
 
Building file: ../b3f/src/test_core.cpp
Invoking: GCC C++ Compiler
g++ -std=c++0x -DELPP_THREAD_SAFE -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"b3f/src/test_core.d" -MT"b3f/src/test_core.o" -o "b3f/src/test_core.o" "../b3f/src/test_core.cpp"


Instead, I need to include the easylogging.cc file in the compilation process of test_core.cpp

Thanks again,

Hakan
Re: Explicitly compiling more than one dependent files in Eclipse CDT [message #1774422 is a reply to message #1774337] Sat, 14 October 2017 05:18 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
g++ compiling multiple source files is no different than compiling them separately then linking the object files.
https://stackoverflow.com/a/3202161

The easiest way to create a project is with File --> New --> C++ project --> Hello World C++ project.
Use the default location (the workspace) or somewhere else then set a project name.
Be sure to select the Linux GCC tool chain.
This will create a directory structure and set up the tool chain properly for a managed build which can be a bit tedious if importing as a makefile project.
The default configuration is Debug.

Delete the created sample source file src/<projname>.cpp
Place your files in the project src directory.
You may need to refresh the project in Project View using F5 afterwards.
Project --> Build Project

I created a test project this way using the main from your link then compiled and linked it.
I called the project easyloggingFirst
The configuration directory (Debug in this case) is created during the build.
It will contain the necessary makefiles, intermediate files and the resultant executable.

index.php/fa/31001/0/
index.php/fa/31002/0/

[Updated on: Sat, 14 October 2017 05:46]

Report message to a moderator

Re: Explicitly compiling more than one dependent files in Eclipse CDT [message #1774450 is a reply to message #1774422] Sat, 14 October 2017 21:50 Go to previous message
Hakan Bayindir is currently offline Hakan BayindirFriend
Messages: 11
Registered: January 2017
Location: Ankara, Turkey
Junior Member

Hi David,

Thanks for your reply. You're correct indeed. The problem was elsewhere inside the library. Since I was using the library for a very long time, my codebase utilizes many of the features of Easylogging++. When I've seen "incomplete type" and "forward declaration" errors, I blindly assumed that they're from the compilation process. However, the problem was more sinister.

Easylogging++'s some features are controlled via #defines, and the developer has disabled some of the normally-enabled features, since not many people have used them. I 've added the required flags, and indeed the code is compiling as it should now.

While I'm not inexperienced in C++, I'm somewhat inexperienced in development of a software of this size.

Thanks for all your help. It was enlightening.

Regards,

Hakan
Previous Topic:Libraries for Arduino plugin
Next Topic:How to activate code completion by Ctrl+Space?
Goto Forum:
  


Current Time: Thu Apr 25 23:33:37 GMT 2024

Powered by FUDForum. Page generated in 0.03361 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top