ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Mon Apr 22, 2019 12:10 pm

All times are UTC




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue Jan 22, 2019 4:37 pm 

Joined: Sat Apr 22, 2017 10:40 am
Posts: 7
No matter what source code I use from https://aluigi.altervista.org/ , I always get mass errors. Im a beginner at programming and it seems no matter what IDE I use it gives me mass errors.
For example : https://aluigi.altervista.org/fakep/tcpfp.zip

Contains two files : winerr.h and tcpfp.c

Now I tried Visual Studio Code, started a new project and now this:

Code:
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x7): undefined reference to `WSAGetLastError@0'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x5ae): undefined reference to `WSAStartup@8'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x921): undefined reference to `htons@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x946): undefined reference to `ntohs@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x95a): undefined reference to `inet_ntoa@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x9c1): undefined reference to `socket@12'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x9ef): undefined reference to `connect@12'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0xa06): undefined reference to `closesocket@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0xc16): undefined reference to `__WSAFDIsSet@8'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0xd23): undefined reference to `select@20'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0xde8): undefined reference to `__WSAFDIsSet@8'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0xe1c): undefined reference to `recv@16'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0xfde): undefined reference to `socket@12'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x1049): undefined reference to `setsockopt@20'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x1077): undefined reference to `setsockopt@20'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x10a5): undefined reference to `setsockopt@20'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x10c5): undefined reference to `connect@12'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x10ff): undefined reference to `closesocket@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x1161): undefined reference to `send@16'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x119c): undefined reference to `closesocket@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x12c3): undefined reference to `closesocket@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x1432): undefined reference to `inet_addr@4'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Dennis\AppData\Local\Temp\ccwJzarD.o:tcpfp.c:(.text+0x1449): undefined reference to `gethostbyname@4'


Suddenly I have to configure some weird tasks.json launch.json files, Internet description is a horror, tried many things and still wont work.

So ok next IDE. JetBrains CLion. Configured the path of Mingw. Now I start a new project with the files in the dir and now I cant even compile it because it says "CMake project is not loaded". What the hell.
When I look at your text at https://aluigi.altervista.org/about.htm it doesnt mention what IDE you use? And "I use ever and only Gcc and its Win32 port Mingw to compile my C stuff." So how do you do it? What if you have 10 or more files?

I cant even copy paste code and compile it please help


Top
   
PostPosted: Tue Jan 22, 2019 11:11 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10177
They aren't errors :)
"undefined reference" means that you must link the executable with the necessary libraries.
Add the following at the end of your gcc command-line and it will work:
-lws2_32

Example:
gcc -o file.exe file.c -s -O2 -lws2_32


Top
   
PostPosted: Wed Jan 23, 2019 9:37 am 

Joined: Sat Apr 22, 2017 10:40 am
Posts: 7
Thanks for the answer. I tried everything and this worked. I seem to get less errors in general from simple -gcc -o test test.cpp line than the big IDEs. Really weird, I expect theses big programs to make it easier not harder.
How do you use that command line if you are using like 20 files? Does this simple line work too?


Top
   
PostPosted: Wed Jan 23, 2019 10:32 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10177
gcc -o file.exe *.c -s -O2 -lws2_32

:D


Top
   
PostPosted: Wed Jan 23, 2019 2:22 pm 

Joined: Sat Apr 22, 2017 10:40 am
Posts: 7
Is there a reason you prefer this over an IDE?

Edit: Also, there are a lot of things in Reverse Engineering (like Memory stuff) which wont work with gcc compiler and you need Microsoft visual 2017. I just tested it.
Gcc/clang gives error, VS doesnt.
I just uploaded a random .zip file which I get from some game hacking site which contains a project with 3 main files (2x cpp and 1 header) and you will not be able to compile it with your way. What do you do?


Attachments:
this.zip [13.31 KiB]
Downloaded 12 times
Top
   
PostPosted: Sun Jan 27, 2019 12:27 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10177
I'm not used to work with IDE on gcc projects, that's why I go directly with the command-line.

If you prefer the "command-line way" with VS projects, you can.
Usually you have just to run "C:\Program Files (x86)\Microsoft Visual Studio XX.0\VC\vcvarsall.bat" which will set the environment and then call cl.exe with the necessary arguments.

I didn't check what's missing with the project you uploaded since I have limited time and it's not my code.


Top
   
PostPosted: Mon Jan 28, 2019 5:48 pm 

Joined: Sat Apr 22, 2017 10:40 am
Posts: 7
thanks for answer


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 7 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited