Hello!
I - am new to programming, C + +. I was given the job. Here it is: to write for Linux daemon which will run wpa_supplicant. I downloaded the documentation, read about what a library wpa_ctrl.c. However, I did not get to use it. I connect it to their function main (), but I get an error. Help me, please!
And these are errors, when I try to run my code in Qt Creator:
1 2 3 4 5 6 7 8 9 10
/home/lucky/Qt/Test-C/main.cpp:7: ошибка: stray '\342' in program
/home/lucky/Qt/Test-C/main.cpp:7: ошибка: stray '\210' in program
/home/lucky/Qt/Test-C/main.cpp:7: ошибка: stray '\227' in program
/home/lucky/Qt/Test-C/main.cpp:1: In file included from main.cpp:1:0:
/home/lucky/Qt/Test-C/wpa_ctrl.h:198: ошибка: 'size_t' has not been declared
/home/lucky/Qt/Test-C/wpa_ctrl.h:199: ошибка: 'size_t' has not been declared
/home/lucky/Qt/Test-C/wpa_ctrl.h:200: ошибка: 'size_t' has not been declared
/home/lucky/Qt/Test-C/wpa_ctrl.h:241: ошибка: 'size_t' has not been declared
/home/lucky/Qt/Test-C/main.cpp:-1: In function 'int main()':
/home/lucky/Qt/Test-C/main.cpp:7: ошибка: variable 'wpa_ctrl ctrl' has initializer but incomplete type
I think you can't include a *.c file, only *.h file
If my understanding is correct the linker will make sure that the actual .c library is compiled with the program.
Someone please correct me if I'm wrong - I belong in the beginners forum.
You can include anything you like. The preprocesser copies the whole thing and dumps it into your code where you #include it. It is up to you to make sure it's sensible to copy and paste the file into that location.
The linker does not work with source code at any point, so assuming a .c file is a plain text file containing source code, it does not work with a .c file. It does work with the compiled .c file, which is generally called an object file.
Thanks for that Moschops :)
Should have put my thinking hat on and have known that the linker doesn't work with source code as it acts after the compiler...
@ lucky spirit, try a google for "has initializer but incomplete type", it will show you a whole bunch of stuff that may be causing the error.
Thank you for your answers! But I do not care as long as I can do nothing. If you help me understand, I am immensely grateful.
I downloaded from the official website source code wpa_supplicant. These sources are packed in archives. Link to it here: http://hostap.epitest.fi/releases/wpa_supplicant-1.0.tar.gz. I also downloaded the documentation for developers on the link: http://w1.fi/wpa_supplicant/wpa_supplicant-devel.pdf. In this document on page number 1 is written as follows:
"wpa_supplicant implements a control interface that can be used by external programs to control the operations of the wpa_supplicant daemon and to get status information and event notifications. There is a small C library that provides helper functions to facilitate the use of the control interface. This library can also be used with C++."
How do I connect this library? In the folder with the source code is a Makefile, but it says to do nothing.
So, I would like to continue this theme. I compiled the source code of wpa_supplicant using the Makefile, which was in the folder. I got to run the compiled Wpa_cli and it worked. Also in the folder / src / utils appeared Library "libutils.a". I plugged it into my project. Still, when compiling I get errors when I connect only wpa_ctrl.c file (within the errors I correct paths): /home/lucky/Qt/wifi_daemon/mywifi.cpp:5: error: 'wpa_ctrl_open' was not declared in this scope
If I connect more and wpa_ctrl.h, then the error is as follows: /home/lucky/Qt/wifi_daemon/mywifi.cpp:-1: error: undefined reference to `wpa_ctrl_open'
Please, help me! I'm trying to deal with this problem for over a week.