I have the below tree:
├── cminpack
│ ├── hybrd.c
│ ├── hybrd.o
│ ├── hybrj1.c
│ ├── hybrj1.o
│ ├── hybrj.c
│ ├── hybrj.o
│ ├── libminpack.a
│ ├── Makefile
│ ├── minpack.h
│ ├── minpack.h.gch
│ ├── readmeC.txt
│ ├── readme.txt
├── greeter.c
├── greeter.h
├── greeter.o
├── swaps.c
├── swaps.h
├── swaps.o
The files:
cminpackis a package I found and copied and I canmakeit successfullyswaps.cis where mymainis, I also do have the below in it:
#include "./cminpack/minpack.h"
#include "./greeter.h"
greeter.cis another file with some functions
In swaps.c I call a function from greeter.c and function hybrd_ from cminpack/hybrd.c. I want to link both greeter and cminpack to my swaps.
I manage to link greeter by running the below gcc command:
sudo gcc -c swaps.c greeter.c ;sudo gcc -o swaps swaps.c greeter.c -lm ;./swaps
Now if I try to link cminpack I am running the below gcc command:
sudo gcc -c swaps.c greeter.c -I./cminpack;sudo gcc -o swaps swaps.c greeter.c -lm -L /cminpack
This leads to the infamous linking error:
/usr/bin/ld: /tmp/ccxwxt6A.o: in function `fsolve':
swaps.c:(.text+0xfb3): undefined reference to `hybrd_'
collect2: error: ld returned 1 exit status
How do I link the subfolder?
(gcc version 10.2.1 20210110 (Debian 10.2.1-6))