-1

I've tried reading through thread after thread and I can't seem to figure out why my main.c cannot reference anything from another other file called deq.c that is located in the same repository. I will attach the makefile code below as well as the error message.

On my main.c file, I'm attempting to make a reference to a method in the file deq.c called deq_new(). This method has already been created and fully implemented.

The error message I get when attempting to run my main file states: "C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MKyle\AppData\Local\Temp\cck9V669.o:main.c:(.text+0x5f): undefined reference to `deq_new' collect2.exe: error: ld returned 1 exit status"

Here is my GNUmakefile provided by my professor. MakeFile image

The code for the Deq_new() method is found inside of the "deq.c" file which is included in the main.c using the #INCLUDE "deq.c" statement at the top.

The method and file are referenced correctly and something must be wrong with my makefile or something when it first attempts to compile after run is clicked. If anybody has any ideas for what else may be causing the main.c to not recognize methods from the other file in the repository, I would really appreciate it!

The main.c code is as follows: main.c file picture

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
  • 5
    Please provide the code as text, not as screenshots, see [this](https://meta.stackoverflow.com/q/285551/2752075) for rationale. We might also need `deq.h`/`.cpp`, but read about [mcve] first. Lastly, don't tag C++ if you code in C. – HolyBlackCat Aug 31 '21 at 05:56
  • And add code from main.c, deq.c, deq.h and your makefile , it will be much more helpful to understand the problem. – Linux Geek Aug 31 '21 at 06:00

1 Answers1

0

You're talking about deq.c, but the makefile references libdec.so.

I'm guessing you've compiled the libdec.so some time in the past or got it as is, changed it and expected the makefile to compile it. It doesn't.

There is some information missing, but from what I can guess from your input, your options are:

  • recompile dec.c to libdec.so with the new function
  • compile dec.c into the executable without going through turning it into a shared object

a simple command you can use to see if you can compile things together:

gcc main.c dec.c -o my_main
Shlomi Agiv
  • 1,183
  • 7
  • 17