[Mingw-users] Fwd: help in the usage of compiling c files

Back to archive index
Francesco Lazzarotto frala****@gmail*****
Fri Sep 25 02:29:49 JST 2020


Hello, you should compile object files and then link, like

cc -g -I. -ansi -Wall -pedantic   -c -o image_size.o image_size.c
cc -g -I. -ansi -Wall -pedantic   -c -o readimage.o readimage.c
cc -g -I. -ansi -Wall -pedantic   -c -o jpegll_enc.o jpegll_enc.c
cc -g -o encoder image_size.o readimage.o jpegll_enc.o -L. -lm

this works for me using gcc 7.5 on Linux, then it's better to put (cc is
alias to gcc)
compile commands in a Makefile such:

text file Makefile:

#---------------------------------------------------
TARGET1=encoder
CC=cc -g

SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
CFLAGS = -I. -ansi -Wall -pedantic
LDFLAGS = -L. -lm

TARGETS = $(TARGET1)

$(TARGET1): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)

all: $(TARGETS)
echo "done all targets"

.PHONY: clean
clean:
rm -f $(OBJ) $(TARGETS)
#---------------------------------------------------

then you can compile with

make

(log files attached, created with make > out.log 2> err.log )
If you want to compile on mingw you need to change cc with
mingw compiler command.
(i686-w64-mingw32-gcc.exe or x86_64-w64-mingw32-gcc.exe on MS win msys2)
you can also remove warnings putting header files as compiler tips write.

Hope this can help you.

Cheers.
Francesco Lazzarotto.


On Thu, 24 Sep 2020 at 18:45, Aileen Sengupta <ailee****@gmail*****>
wrote:

>
> ---------- Forwarded message ---------
> From: Aileen Sengupta <ailee****@gmail*****>
> Date: Mon, 21 Sep 2020, 01:18
> Subject: help in the usage of compiling c files
> To: <mingw****@lists*****>
>
>
>
> Dear Team,
>
> I have recently installed the MinGW and I am trying to run the following
> command
> gcc -o encoder jpegll_enc.c idc.h readimage.c image_size.c and I get the
> following error:
>
> [image: image.png]
>
> I have all the necessary files in the same folder as shown in the command
> prompt.
> I have attached the files in the email. I have tried every possible
> solutions and I needed help. Can you help me with the possible solution?
> --
> Thanks and Regards,
> Aileen Sengupta
>
> https://sites.google.com/site/aileensengupta/
> https://in.linkedin.com/in/aileen-sengupta-91547a24
> _______________________________________________
> MinGW-Users mailing list
> MinGW****@lists*****
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list
> etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.osdn.me/mailman/listinfo/mingw-users
> Also: mailto:mingw****@lists*****?subject=unsubscribe



-- 
******************************************************************
*** PLEASE NOTE MY PERSONAL EMAIL ADDRESS
*** HAS CHANGED TO frala****@gmail*****
******************************************************************
Francesco Lazzarotto
mailto:frala****@gmail*****
skype:fralaz1971
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200924/4c790a59/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 52078 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200924/4c790a59/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 281 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200924/4c790a59/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.log
Type: text/x-log
Size: 259 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200924/4c790a59/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: err.log
Type: text/x-log
Size: 1077 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200924/4c790a59/attachment-0003.bin>


More information about the MinGW-Users mailing list
Back to archive index