Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Annoying error, help?

Hi so im trying to make a port scanner on my tool but i cant seem to compile?

Error code when compileing:
Code
-*- mode: compilation; default-directory: "c:/emacscode/Sec2/" -*-
Compilation started at Fri Sep 27 16:38:55

g++ StoneCodedPanel.cpp -o SCP
C:\Users\denni\AppData\Local\Temp\ccLdspLG.o:StoneCodedPanel.cpp:(.text$_ZN9powermode11portscannerEv[__ZN9powermode11portscannerEv]+0xe1): undefined reference to `_imp__socket@12'
C:\Users\denni\AppData\Local\Temp\ccLdspLG.o:StoneCodedPanel.cpp:(.text$_ZN9powermode11portscannerEv[__ZN9powermode11portscannerEv]+0xfd): undefined reference to `_imp__htons@4'
C:\Users\denni\AppData\Local\Temp\ccLdspLG.o:StoneCodedPanel.cpp:(.text$_ZN9powermode11portscannerEv[__ZN9powermode11portscannerEv]+0x121): undefined reference to `_imp__connect@12'
C:\Users\denni\AppData\Local\Temp\ccLdspLG.o:StoneCodedPanel.cpp:(.text$_ZN9powermode11portscannerEv[__ZN9powermode11portscannerEv]+0x185): undefined reference to `_imp__closesocket@4'
collect2.exe: error: ld returned 1 exit status

Compilation exited abnormally with code 1 at Fri Sep 27 16:38:56

The Whole code:

Code
https://pastebin.com/hiekA20L
Did you forget to link it with the library?
You can link it with -lws2_32
yikes...that code looks...hideous
(Sep 27, 2019 09:25 AM)YouthInAsia Wrote:  yikes...that code looks...hideous

Yeah i know, but instead of bashing it, maybe help me instead? how would you do it?


(Sep 27, 2019 09:18 AM)ShallowME Wrote:  Did you forget to link it with the library?
You can link it with -lws2_32

Maybe thats what i need to do, but kinda dont know how?
thanks,
(Sep 27, 2019 09:59 AM)pms Wrote:  Yeah i know, but instead of bashing it, maybe help me instead? how would you do it?



Maybe thats what i need to do, but kinda dont know how?
thanks,

After offering free help for 8 years on HF I'm pretty much done giving free constructive criticism. I'd be more than happy to help you for a price
Add this in top of your code. in case of VS, I believe gcc has their own set of #pragma's
Code
#pragma comment(lib, "ws2_32.lib")
Here's a tiny suggestion list for you:

  1. Avoid using macros ("chatCOLOR"); prefer type-safe constructs

  2. Use a better naming convention; camelCase, Hungarian notation or other are fine (powermode -> cPowerMode)

  3. Prefer std::string over POD char-arrays (char IP[20] -> std::string)

  4. Use the using keyword for small projects (using std::cout; using std::string; etc)

  5. Avoid using Sleep(); try to set up a callback function and a state checker for network activity or something else



A slightly improved version of the macro (if you choose to keep it) might be:
Code
#define chat(COLOR) SetConsoleTextAttribute(color, COLOR);
chat(125)

Also consider splitting up your monolithic class into separate, logical objects that each accomplish a goal.

It appears that you are trying to write with a procedural paradigm while encapsulating it into a single object (class).

That's all.
Is there any such thing as a woman of honor, and sincerity?

https://www.PutItOnMute.com/

4K HDR, WDR time-lapsed truck driving videos!
(Sep 27, 2019 06:39 PM)Irritiable Wrote:  
  1. Use a better naming convention; camelCase, Hungarian notation or other are fine (powermode -> cPowerMode)




I personally prefer Google's C++ naming convention. I had too much of camelCase and szHungarianNotation back in my early days and now i'm sick of seeing it.
g++ StoneCodedPanel.cpp -lws2_32 -o SCP

Use the above command to compile your binary.
Wow thank you all for the support and help here. Will be doing these things :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by D_MuLaOct 7, 2016 03:27 PM 10 250 Oct 7, 2016 03:27 PM
Last Post: 0xDEAD10CC
[.NET] by javiermadAug 30, 2014 11:00 AM 17 467 Aug 30, 2014 11:00 AM
Last Post: LucidLullabies
[Python] by NewbHacker62Oct 11, 2013 07:31 PM 4 84 Oct 11, 2013 07:31 PM
Last Post: monkeytherat