Hack Forums
[C] Compiling C Scripts Error - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] Compiling C Scripts Error (/showthread.php?tid=4840908)

Pages: Pages 1 2


Compiling C Scripts Error - Kumara - May 28, 2015

Hello, I'm having an error compiling a C script. I'm using GCC to compile.
It's a DNS scanner, but the problem persists with all my scanning scripts. DNS scanner source code: http://pastebin.com/Ay8cQYUS

dns.c:12:21: error: stropts.h: No such file or directory
dns.c: In function ‘flood’:
dns.c:103: warning: cast from pointer to integer of different size
dns.c: In function ‘main’:
dns.c:239: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
/usr/include/pthread.h:225: note: expected ‘void (*)(void )’ but argument is of type ‘void (*)()’
dns.c:254: warning: cast to pointer from integer of different size

Anyone know how to fix this?

Thanks.


* - g4143 - May 28, 2015

Anyone know how to fix this?

Yeah its line 300 in stropts.h.

How do you except us to help with no source code?


* - Kumara - May 28, 2015

(May 28, 2015 11:02 PM)g4143 Wrote:  Anyone know how to fix this?

Yeah its line 300 in stropts.h.

How do you except us to help with no source code?

http://pastebin.com/Ay8cQYUS
That's the source code.


* - g4143 - May 28, 2015

Do you have to link a shared object for stropts?


* - Kumara - May 28, 2015

(May 28, 2015 11:09 PM)g4143 Wrote:  Do you have to link a shared object for stropts?

Say again? I didn't understand what you meant.


* - Mic Righteous - May 28, 2015

add "-pthread" at the end of the gcc command.

Example:
gcc script.c -o script -pthread


* - g4143 - May 29, 2015

(May 28, 2015 11:24 PM)Mic Righteous Wrote:  add "-pthread" at the end of the gcc command.

Example:
gcc script.c -o script -pthread

The pthread problem wasn't a missing shared object. It was an incorrect function signature.

Quote:dns.c:239: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
/usr/include/pthread.h:225: note: expected ‘void (*)(void )’ but argument is of type ‘void (*)()’
dns.c:254: warning: cast to pointer from integer of different size



* - Kumara - May 29, 2015

(May 29, 2015 01:43 AM)g4143 Wrote:  The pthread problem wasn't a missing shared object. It was an incorrect function signature.

Could you perhaps give me a fix?


* - g4143 - May 29, 2015

(May 29, 2015 01:48 AM)Greenpoison Wrote:  Could you perhaps give me a fix?

Well the pthread warning is the function signature here.
Code
void recievethread(){
.....
}

it should be.
Code
void recievethread(void){
.....
}



* - Kumara - May 29, 2015

(May 29, 2015 02:01 AM)g4143 Wrote:  Well the pthread warning is the function signature here.
Code
void recievethread(){
.....
}

it should be.
Code
void recievethread(void){
.....
}

Thank you. I will test the fix ASAP.


* - Mouse❤️ - May 29, 2015

Also for the record, there's no way you wrote this but don't know that the problem is you're missing a header. You should probably stop stealing other people's code and learn how to write your own. That's one way to fix your problems.


* - g4143 - May 29, 2015

(May 29, 2015 06:08 AM)-Mouse- Wrote:  Also for the record, there's no way you wrote this but don't know that the problem is you're missing a header. You should probably stop stealing other people's code and learn how to write your own. That's one way to fix your problems.

Actually to OP did post the code with the header file but that doesn't mean its a correct header file or that the header file is present on their machine.


* - Mouse❤️ - May 29, 2015

That's what I'm saying. He wrote all that code, but he couldn't understand "dns.c:12:21: error: stropts.h: No such file or directory". The code references a header file that's not there and he can't comprehend that.


* - g4143 - May 29, 2015

(May 29, 2015 06:48 AM)-Mouse- Wrote:  That's what I'm saying. He wrote all that code, but he couldn't understand "dns.c:12:21: error: stropts.h: No such file or directory". The code references a header file that's not there and he can't comprehend that.

Well the problem could be a number of things and all of them are compiler/linker problems which can be nasty if you neglected that part of your C/C++ training.


* - Mouse❤️ - May 29, 2015

True, true. I'm just not open to trusting new HF users that just show up with code that "doesn't work for some reason"