Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Include Header files in Eclipse(I need a beginner version on how to add header files and )
Include Header files in Eclipse [message #1839122] Mon, 15 March 2021 06:44 Go to next message
Luca Fleischanderl is currently offline Luca FleischanderlFriend
Messages: 2
Registered: March 2021
Junior Member
So first of all, I'm completely new to Eclipse , I have learned C++ for about 5 months now and this is probably some basic stuff for y'all.

I use Eclipse IDE for C/C++ Developers - Version 2020-12 (4.18.0) on a MacBook Pro - macOS Big Sur - Version 11.2.1.

First: For my study I have to include two header files to my eclipse. "CImg.h" and "Drawing.h" and I should link a Drawing.cpp file as well. How do i do this?

Second: I should also add the files "pthread" and "X11".

I have instructions (I put them at the end for you) for Linux but when I follow them step by step it doesn't work on my Mac.

There are loads of errors appearing but in the line of #inlcude "Drawing.h" it says "unresolved inclusion" so where do I have to do something else?

I would really appreciate your help as I need this to get started!


These are the instructions that should work on Linux:

"Project -> Properties -> C/C++ General -> Paths and Symbols -> Includes -> GNU C++ -> Include directories -> Add" choose the installation paths of "CImg.h" and "Drawing.h"

"Project -> Properties -> C/C++ General -> Paths and Symbols -> Libraries -> Add" add the file "pthread" and "X11" (just type the name)
Re: Include Header files in Eclipse [message #1839145 is a reply to message #1839122] Mon, 15 March 2021 18:26 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
The files pthread and X11 are Linux-specific. It is fairly possible that you will not be able to use them directly in MacOS, especially on Big Sur which seems to have more than its share of compatibility problems.


--

Tauno Voipio
Re: Include Header files in Eclipse [message #1839153 is a reply to message #1839145] Tue, 16 March 2021 07:05 Go to previous messageGo to next message
Luca Fleischanderl is currently offline Luca FleischanderlFriend
Messages: 2
Registered: March 2021
Junior Member
Oh ok, then I need to talk to my professor if there is any other possibility.

Thanks for your reply!
Re: Include Header files in Eclipse [message #1839278 is a reply to message #1839122] Thu, 18 March 2021 15:09 Go to previous messageGo to next message
madanswer ask is currently offline madanswer askFriend
Messages: 1
Registered: March 2021
Junior Member
you can follow below steps for the same


    Right click on the project and select properties.
    Select C/C++ General -> Path and Symbols.
    Select Includes tab.
    In Languages list, select 'GNU C' or whatever C compiler tool chain you use.
    Press 'Add...' button and add the directory for the include files.
    Close Properties window and rebuild. You should see new path being used as -I in build process.

Re: Include Header files in Eclipse [message #1860998 is a reply to message #1839278] Wed, 13 September 2023 22:33 Go to previous messageGo to next message
Bob Slotpole is currently offline Bob SlotpoleFriend
Messages: 3
Registered: September 2023
Junior Member
this just doesn't work!! could some one provide step by step instructions that actually work!!!!
Re: Include Header files in Eclipse [message #1861004 is a reply to message #1860998] Thu, 14 September 2023 08:13 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
There is no way to respond to your question, as there are no details on:
- what are you attempting to achieve,
- what is the computer and operating system you are targeting.

There is no simple way to make the setup of the original question to work. It seems to me that the code is targeted to the X window graphical user interface, and it is different from both the Microsoft Windows and Mac OS.


--

Tauno Voipio
Re: Include Header files in Eclipse [message #1861031 is a reply to message #1861004] Thu, 14 September 2023 19:37 Go to previous messageGo to next message
Bob Slotpole is currently offline Bob SlotpoleFriend
Messages: 3
Registered: September 2023
Junior Member
Hi, do you know how to add a shared library on windows 10 in eclipse for C?
Here's what I've tried to do:

On Windows 10, using eclipse for c projects I have installed the MinGW compiler. I've been able to add a static library (*.h, *.c files). I can't for some reason get a shared library to work.

I notice that for my shared library I generate a *.o file and a *.dll file but I am not creating a *.so file.

Here are the steps I'm taking:

1) open eclipse in new workspace
2) create a new c project
a) project name ->SharedLib
b) project type -> shared Library -> empty project
c) toolchain -> MinGW GCC
3) In SharedLib folder
a) create test.h (header file) and test.c (source file)

test.h

#ifndef TEST_H_
#define TEST_H_
void test_print(void);
#endif /* TEST_H_ */

test.c

#include <stdio.h>
void test_print(void){
printf("we have lift off");
}
4) build Sharedlib
a) creates Binaries -> libSharedLib.dll
5) create new c project Exec
a) empty project
b) add source file main.c

main.c

#include <stdio.h>
#include "test.h"
int main(void){
printf("we are on the launch pad");
test_print();
}
6) go into properties of Exec->Paths and Symbols->references
a) choose SharedLib, apply and close

7) build all and then run
I have no error messages and no output. the only thing it says is:

<terminated>(exit value: -1,073,741,515)Exec.exe[C/C++ Application]
D:\workplace3\Exec\Debug\Exec.exe(9/14/23,3:05pm)
Could really use some help getting this to work.

The goal is to get this shared library automatically included in all my c projects

[Updated on: Thu, 14 September 2023 19:57]

Report message to a moderator

Re: Include Header files in Eclipse [message #1861051 is a reply to message #1861031] Fri, 15 September 2023 18:22 Go to previous message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
This is actually an off-topic for Eclipse, it is about installing a shared library for use with MinGW.

A MinGW forum may be better for a discussion.

Sorry, I do not have a working Windows installation to check. Last one was a XP not more activated.
My guess is that you have to introduce the DLL to Windows.


--

Tauno Voipio
Previous Topic:How to install C compiler for Eclipse
Next Topic:GDB Tracepoint Analysis display timestamp
Goto Forum:
  


Current Time: Thu Oct 03 20:31:07 GMT 2024

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

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

Back to the top