0

Im trying to create an application that connects to my wifi, but I did not get really far. Look at my small application (main.c):

#include <stdio.h>

#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/wifi_mgmt.h>
#include <zephyr/net/net_event.h>

int main(void)
{
    printk("Application start\n");

    struct net_if *iface = net_if_get_default();

    return 0;
}

The error I get:

main.c: undefined reference to `net_if_get_default'

I dont really understand it because i include it with net_if.h file, and my esp32s2_saola.overlay content:

&wifi {
    status = "okay";
};

So it should be all ok?

u314
  • 87
  • 1
  • 7
  • Missing source file, object file or library when you link? – Some programmer dude Aug 26 '23 at 15:40
  • According to the documentation (https://docs.zephyrproject.org/apidoc/latest/group__net__if.html#ga55214771e462cbd4930ffa738813cb87) that function should be declared in net_if.h. I don't understand how you get this error, but not one on your include. What version of Zephyr are you using? – mzimmers Aug 26 '23 at 17:04
  • @mzimmers From what I can gather im on 3.3.99. Current is 3.4.0 so it isnt that bad. Aint from the stoneages so should "be working" – u314 Aug 26 '23 at 17:35
  • @Someprogrammerdude unsure on how to differentiate. I see 'bin/ld.bfd.exe: app/libapp.a(main.c.obj):(.literal.main+0x4): undefined reference to `net_if_get_default'' but there is alot – u314 Aug 26 '23 at 17:43
  • How much do you know about C application development? Do you know the stages that happens when you build a C application? First the compiler takes a source file and include all header files, forming a [*translation unit*](https://en.wikipedia.org/wiki/Translation_unit_(programming)). The compiler generates an *object file*. Then another programs takes all object files and all libraries and creates the actual executable program, or binary image used for the target system on embedded systems. The errors you get is from the linker, not compiler. – Some programmer dude Aug 26 '23 at 19:25
  • You get errors from the linker because you don't link with all object files needed, or not all the libraries needed. You need to read the documentation to learn what libraries to link with. – Some programmer dude Aug 26 '23 at 19:26

0 Answers0