Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with implementing a basic Makefile in c
    primarykey
    data
    text
    <p>Okay so I need to make a basic Makefile for a program I wrote. Here are the files:</p> <pre><code>list.c hash.c order_book.c libdefault_hash.a //provided already so I do not need to create. </code></pre> <p>I need to create libraries for list.c and hash.c so that orderbook can use them when it compiles. So this is what I currently have in <code>Makefile</code>:</p> <pre><code>all: orderbook orderbook: orderbook.c liblist.a libhash.a gcc -std=c99 -o orderbook order_book.c list.c -L. -llist -lhash -libdefault_hash liblist.a: list.c gcc -std=c99 -c list.c ar rcu liblist.a list.o libhash.a: hash.c gcc -std=c99 -c hash.c ar rcu libhash.a hash.o </code></pre> <p>My understanding of how makefiles work is very small but here is my thought process,</p> <ol> <li><code>all: orderbook</code> will mean that <code>orderbook:</code> will run.</li> <li><code>orderbook.c</code> will then compile, then the code will compile the libraries.</li> <li><p>Once the libraries are compiled it will run:</p> <p><code>gcc -std=c99 -o orderbook order_book.c list.c -L. -llist -lhash -libdefault_hash</code></p></li> </ol> <p>And the result should be a simple program file named orderbook, but the terminal prints out:</p> <pre><code>$ make gcc -std=c99 -o orderbook order_book.c list.c hash.c -L. -llist -lhash -libdefault_hash /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: skipping incompatible ./liblist.a when searching for -llist /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -llist /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -libdefault_hash collect2: ld returned 1 exit status make: *** [orderbook] Error 1 $ </code></pre> <p>Any help/guidance is much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload