Hello everybody!
I would like to know "how to link header file (.h file ) and source file (.c file ) in c.
I have downloaded many .h files and .c files. I have noticed that the functions are declared in .h files and denined in .c files. I don't know how to link them in main program.
Please explain me.
thanks in advance,
Moe

.h files are includes in .c files

// myfile.c
//
#include "myheader.h"
// rest of c program here

Then run your compiler against all the *.c files. It will create *.obj files which can be used by the linker to create the executable file.

Beyone that, how to do all the above depends on the compiler and operating system you are using.

.h files are includes in .c files

// myfile.c
//
#include "myheader.h"
// rest of c program here

Then run your compiler against all the *.c files. It will create *.obj files which can be used by the linker to create the executable file.

Beyone that, how to do all the above depends on the compiler and operating system you are using.

When I compile *.c files, most of them have many errors.
So I think I can not create obj file.
I have downloaded that for link grammar api.
http://www.link.cs.cmu.edu/link
I think that can not have error.Can you please test that for me.

Ancient Dragon

Your mean I have to create obj file by compiling *.c file.Yes, I can compile that.
After that what should i do?

What compiler are you using? If you use Microsoft Visual C++ 2005 Express, the download includes project files.

If that is your compiler, then the compiler will spew out a whole bunch of warnings about using deprecated C functions. you can disable the warning with a pragma. put this at the top of link-includes.h. Otherwise everyting compiled and linked ok for me using VC Express compiler.

#pragma warning(disable: 4996)

Don't laugh at me.
I am using turbo c compiler. It is an ancient software.
I also try to use Borland 5.5. But that gives many error when I compile .c file.

Don't laugh at me.
I am using turbo c compiler. It is an ancient software.
I also try to use Borland 5.5. But that gives many error when I compile .c file.

:cheesy: :cheesy: :cheesy: :cheesy: :cheesy: :cheesy: :cheesy:

trash those old ancient compilers! you can get pretty good free compilers, such as the Express I mentioned previously or Dev-C++ from www.bloodshed.net.

I think I cannot use vc.
I would like to write my project in c.

You are also ancient dragon.
Are you good?
It is just joke.
Please guide me.

You are also ancient dragon.
Are you good?
It is just joke.
Please guide me.

Sorry -- I couldn't resist the laughter.

you cannot use TC because it is too old and does not know about long file names -- file names that are longer than 8 characters followed by a perios and 3 characters for the extension. That is the ancient MS-DOS format. The files in the download you are trying to compile have long filenames.

Ancient Dragon
Where are you going?
I am waiting for you.
I would like to test that api program in c, not vc.
Please help me.
How to link that file?

>> would like to test that api program in c, not vc.

you won't test it with Turbo C. See my previous post (I changed it so you might have to re-read it)

ancient dragon
I have to go back to hostel for roll call.
Thank you for your time and kindness.
I will come back.

Ancient Dragon
When I used TC, I saved as the file name with original name. It is ok.
If tc is not useful, please help me with Borland c 5.5.
Please test it for me.Please

Please let me explain my process in detail.
I have downloaded link grammar api from http://www.link.cs.cmu.edu/link/.
When I tried to discuss in link-grammar forum, they think it was c language problem. When I tried in this forum, you may think it is also off-topic. I don't know what I should do.
I have download the latest version of the linkgrammar parser, link41b. In that downloaded folder, there are may .h files and .c files( including api-example.c) file. I would like to test that api-example.c file in c (not vc).Every header files are under "link-includes.h". In every .c file , "link-includes.h" is declared. It is original code.

Now I am using Borland c 5.5 compiler. I have trashed the antique software tc according to your instruction.
I put all include(.h) files into c:\bcc55\include. And I put all (.c) files into c:\bcc55\bin. Which step I need to process more?
When I compile api-example.c file, there are many errors such as
Error: Unresolved external " parse-options-create( )" referenced from c:\windows\API-EXAMPLE-OBJ
What is the error?
You may say u don't know that compiler. But I think you can guess which step I have to do.

I am from a developing country. Everything is new and difficult for me.

first you have to know how to create projects with that compiler. You cannot use just one of the *.c files from that library, but you have to compile all of them and link them all together. There are 29 *.c files that you must compile and link together. If that is a command-line driven compiler you will probably have to create a makefile that contains all the instructions your compiler needs to compile all those *.c files and create the executable program. If you would get the free copy of VC the IDE will do that for you. If you have IDE with Borland then it might do it too.

You should not have copied the *.h files into your compiler's include directory. That directory should just contain the files that are supplied by your compiler. Compilers have options to tell it where else to look for include files. VC++ has -I flag, such as "I\c:\mydirectory\include" will tell the compiler other .h files are located.

Remove the files you copied into the bcc5/bin and include directories and try following steps below. I used the Visual Studio Command line so the compiling commands in bcc may be different.

1. Extract all the files to any directory you want. I used a directory called lnk41b so the directory tree was like this.

lnk41b
├─data
│  └─words
├─Debug
├─include
├─Release
└─src

2. open the link-includes.h file and add the following lines and save.

///////////////// Add these lines
#ifndef WIN32
#define WIN32
#endif
////////////////////////////////////////////
#ifndef _LINKINCLUDESH_
#define _LINKINCLUDESH_

3. move the following files in the src directory to another directory. Dont delete them you will need them later.

api-example.c
constituent-example.c
www-parse.c

4. Go to the src directory in the command-prompt and compile the remaining files in the src folder as folllows.

src> cl /EHsc *.c /I ..\include

5. move the api-example.c file back into the src directory.
6. delete the parse.obj file in the src directory.
7. compile the api-example.c file as follows.

src> cl /EHsc api-example.c /I ..\include /link *.obj

8. Copy the contents of the data directory to the src directory.
9. run the api-example.exe file in the command-prompt.

src> api-example.exe

I am from a developing country

where are you from? :cheesy:

Moe: does that Borland 5.5 compiler support long filenames (it too is pretty old) If it does NOT then you will have to get a different compiler. Otherwise if it does then it should be ok.

Ancient Dragon & wolfPack
Thank you for your reply. But I have not got that.

Ancient Dragon & wolfPack
Thank you for your reply. But I have not got that.

You have not got what? Just try out the steps I pointed out and see what happens? If you dont know how to compile in bcc, look at the borland c website. They should have some examples on compiling in bcc55.

4. Go to the src directory in the command-prompt and compile the remaining files in the src folder as folllows.

src> cl /EHsc *.c /I ..\include

In Bcc55, the compile instruction is Bcc32.
I don't know the meaning of the above commands.
So I compile as
src>bcc32 /EHsc *.c / I ..\include

But there are many many compile errors including "enable to open "link-includes.h"

What is the problem?Please reply to me.

I have to go back to hostel for roll call.
I will come back tomorrow morning.
Please guild me.

I tried using bcc. It gave me a headache. You have two options.
1. Download the Visual C++ 2003 Command Line tools here and try my method. It is about 32 MB and free.
2. Wait till someone who knows Borland to convert the Visual C++ compiling commands to bcc.

by the way, I really want to know where you are from. :-|

I am not from Japan.

I am not from Japan.

Japan is not a developing country. Now where are you from?

by the way, I really want to know where you are from

I am not from Japan.

Now that we know where you are NOT from, where among the 1,000 or so other nations on this earth are you from :cheesy:

I am also not from USA.

Don't laugh at me.
Now I am preparing to be scolded.


by the way, I really want to know where you are from. :-|

Ooooh I think I know. I think moe is from

[read Phonetically]
Uranus
[/Phonetically]

Was dat better than a scolding? Tee he he.