-1

I am trying to use a linear algebra package called hnfprof. I have done the installation with the given instructions and now its ready to use. Now I want to use some functions in hnfproj/src/lift/lift.c file. I want to create my own matrix examples and check outputs for each functions separately. I am not clear how to do this. (I know only basics of C language, creating .c files in a folder and running it in my Ubuntu terminal.) I know that I should write a C file including this "#include <lift.c>" file name and creating a matrix in my file "main.c". I don't know how to include a file name in a different location. When I compile I can not use "gcc -o program main.c lift.c". My "main.c" file is in a different folder. I don't want to create any make file inside the package folder. So how I can just use the "lift.c" file inside my "main.c" file which is in a separate folder "Main" and create all executable make files inside "Main" folder?

If its difficult to give a answer, appreciate if you can suggest me some source to learn this. Thank you

student
  • 7
  • 1

1 Answers1

0

No need to include lift.c directly in main.c, and you can call function in lift.c from main.

When it comes to compilation, you can use:

gcc -o program main.c file_location/lift.c

If you need other options, add them (most flags at the start; libraries at the end, after the source code). You can also compile each file to object code separately and then link the object files together:

  gcc -c main.c
  gcc -c file_location/lift.c
  gcc -o program main.o lift.o

refer

Compiling multiple C files with gcc

jjm
  • 431
  • 3
  • 19