Compiling c program with dependencies, h and h0 files

1.2k views Asked by At

I am trying to compile the gjh solver - written in C - into an executable file in windows. It is available on netlib

I downloaded the c file and am using gcc compiler via WinGW on windows' command prompt. Trying to compile the gjh.c file directly gave me an error that says:

gjh.c:33:21: fatal error: getstub.h: No such file or directory
 #include "getstub.h"
compilation terminated.

I assumed that compiling gjh.c requires the dependency getstub.h.

getstub.h is not the only dependency required, there are other dependencies, namely: arith.h, asl.h, funcadd.h, and stdio1.h. All of these files are available on the same link where I found getstub.h. However, arith.h0 and stdio1.h0 are available instead of arith.h and stdio1.h.

Are these files the same? I tried to rename the .h0 files to .h and tried to compile gjh.c, but I got this error:

collect2.exe: error: ld returned 1 exit status

Are the two files the same? If not, is there any way for me to compile the gjh solver successfully into an .exe?

1

There are 1 answers

0
adrtam On

If that's the only problem in compiling, try using the -I switch in gcc:

gcc -I/my/path/to/include/files -o gjh gjh.c

the -I switch hints to gcc where to find your #include files.

I am not sure about the stdio1.h. I think your approach to rename is OK but that reference to external functions such as Sprintf. You need to link with a library defining that. If you know where it comes from, use the -L and -l switch in gcc for that:

gcc -I/my/path/to/include/files -L/my/path/to/library -lnameoflibrary \
    -o gjh gjh.c