Correct setup to compile c code under Windows?

41 views
Skip to first unread message

Cleverson Casarin Uliana

unread,
Feb 4, 2019, 6:45:41 AM2/4/19
to 4th-co...@googlegroups.com
Hello all,

I have the minGW GCC Windows port installed under the C:\mingw64
directory. I have just installed 4th and generated a c source from a
first program I've written. Upon reading the c code, I noticed it
contains a #include "4th.h" directive, so after searching a bit, I found
the 4th.h file inside sources.zip, which was installed in the 4th dir.
then I extracted and placed 4th.h inside
C:\mingw64\x86_64-w64-mingw32\include, and tried to compile my c code,
but I returns the following error (I'm including the command I issued):
E:\programas\Forth-exercs>gcc -o teste-acent teste-acent.c -l4th
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -l4th
collect2.exe: error: ld returned 1 exit status

What files I'm suposed to take, and where to place them please?

Running Windows 10 Pro 64-bit.

Thanks in advance.
Cleverson

The Beez

unread,
Feb 4, 2019, 7:19:07 AM2/4/19
to 4tH-compiler
Hi!

- Usually, "make install" will place the libs in the correct place. I
dunno whether it works as advertised under mingGW. Your message suggests
the linker couldn't find them;
- Yes, you will need 4th.h in order to compile your own programs and it
is best to place it in the working directory where your C-sources
reside;
- I will assume you really GENERATED the source and did not make a .h
file of an .hx bytecode program;
- If you DO have a library "lib4th.a" in your working directory "gcc -o
teste-acent teste-acent.c -L. -l4th" should probably work;
- If not, copy "cmds_4th.h", "exec_4th.c" and "errs_4th.c" in your
working directory and issue: "gcc -o teste-acent exec_4th.c errs_4th.c
teste-acent.c";
- When you issue -DUSEGCCGOTO you may also require "gcc_exec.h";
- Note that the source tarball still denotes a 32bit implementation -
this may change in the near future. However, if you generated a source
from the 32bit executable you CANNOT compile it under 64bit. Generate a
true 64bit "4th" first. This may require some tinkering since I do not
have a Win64 Makefile (yet);

More info:

64-bit architectures
====================
If you happen to compile 4tH on 64-bit architectures, you will find that
some functionalities don't work as advertised. In that case, perform the
following procedure:
cd sources
cp include/* .
make clean
make

This will make the executables fit for your 64-bit machine.

So, delve into the Development Guide, section "Compiling 4th" and
further. Don't hesitate to contact me if things get hairy ;-)
And if you figure it out, please lemme know. You will help other users
if you do.

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages