You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by murat tologlu <mt...@hotmail.com> on 2021/07/03 09:35:59 UTC

Formal way of using Nuttx-Posix libraries

Hi,

I am doing experiments of porting standard posix applications to Nuttx, I try to run same applications on both Ubuntu and Nuttx.  In one application I needed to use socket.h, I did "#include <sys/socket.h>" in my c file but it seems that the linker doesn't find the library, I get "undefined reference to `socketpair' 'send' 'recv' errors while all of them clearly defined in sys/socket.h ! 

Of-course I can modify the c file, Makefile, I can move or copy library files to appropriate locations to resolve the problem, but I would like to learn the formal (preferred) way of resolving this issue on Nuttx 
 because the same code compiles and runs on Ubuntu without any modification other than removing <nuttx/config.h>.

BR
Murat

Re: Formal way of using Nuttx-Posix libraries

Posted by Nathan Hartman <ha...@gmail.com>.
On Sat, Jul 3, 2021 at 5:36 AM murat tologlu <mt...@hotmail.com> wrote:

>
> Of-course I can modify the c file, Makefile, I can move or copy library
> files to appropriate locations to resolve the problem, but I would like to
> learn the formal (preferred) way of resolving this issue on Nuttx
>  because the same code compiles and runs on Ubuntu without any
> modification other than removing <nuttx/config.h>.


This is not an answer to your question (I'm not sure why that is happening
and away from a computer so I can't try to reproduce it now) but just
wanted to point out that you don't have to remove the #include
<nuttx/config.h> even when compiling on Ubuntu or other OS. You can wrap
that include with #ifdef __NuttX__ ... #endif. The toolchain built with
NuttX's buildroot defines that symbol, and if you use other toolchains you
can add this define to the compiler command line in your board's Make.defs
file. Then you can build the exact same source file without modifications
or the need to maintain separate branches. (Caveat: I'm writing this all
from memory so it's possible some of the names aren't exactly correct, or
I'm forgetting some detail.)

Hope this is somehow helpful and that you will discover the solution to
your actual question very soon...

Cheers,
Nathan

Re: Formal way of using Nuttx-Posix libraries

Posted by murat tologlu <mt...@hotmail.com>.
Thanks for your kind answers and help, I always appreciate.

@Alan OK I will try using USB console according to your tutorial to continue my experiments.

@Nathan yes I already removed #include <nuttx/config.h> and I don't have problem in Ubuntu, my code compiles and runs as expected. I am also aware of that this issue has been many times before however I couldn't resolve the issue, but working on it. I will try to get help from your explanations.

On 2021/07/04 18:12:11, Nathan Hartman <ha...@gmail.com> wrote: 
> > On Sunday, July 4, 2021, murat tologlu <mt...@hotmail.com> wrote:
> > > > netlib_setifstatus.c: In function 'netlib_ifup':
> > > > netlib_setifstatus.c:67:27: error: 'NETLIB_SOCK_TYPE' undeclared (first
> > > use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
> > > >    67 |                           NETLIB_SOCK_TYPE,
> > > NETLIB_SOCK_PROTOCOL);
> > > >       |                           ^~~~~~~~~~~~~~~~
> > > >       |                           NETLIB_SOCK_FAMILY
> > > > netlib_setifstatus.c:67:27: note: each undeclared identifier is reported
> > > only once for each function it appears in
> 
> Note that this issue has been seen before. See:
> 
> https://github.com/apache/incubator-nuttx-apps/issues/375
> 
> NETLIB_SOCK_TYPE is defined in the incubator-nuttx-apps repository in
> include/netutils/netlib.h and its definition depends on the following
> Kconfigs:
> 
> [[[
> 
> /* Using the following definitions, the following socket() arguments should
>  * provide a valid socket in all configurations:
>  *
>  *   ret = socket(NETLIB_SOCK_FAMILY, NETLIB_SOCK_TYPE,
>  *                NETLIB_SOCK_PROTOCOL);
>  */
> 
> /* The address family that we used to create the socket really does not
>  * matter.  It should, however, be valid in the current configuration.
>  */
> 
> #if defined(CONFIG_NET_IPv4)
> #  define NETLIB_SOCK_FAMILY  AF_INET
> #elif defined(CONFIG_NET_IPv6)
> #  define NETLIB_SOCK_FAMILY  AF_INET6
> #elif defined(CONFIG_NET_LOCAL)
> #  define NETLIB_SOCK_FAMILY  AF_LOCAL
> #elif defined(CONFIG_NET_PKT)
> #  define NETLIB_SOCK_FAMILY  AF_PACKET
> #elif defined(CONFIG_NET_CAN)
> #  define NETLIB_SOCK_FAMILY  AF_CAN
> #elif defined(CONFIG_NET_IEEE802154)
> #  define NETLIB_SOCK_FAMILY  AF_IEEE802154
> #elif defined(CONFIG_WIRELESS_PKTRADIO)
> #  define NETLIB_SOCK_FAMILY  AF_PKTRADIO
> #elif defined(CONFIG_NET_BLUETOOTH)
> #  define NETLIB_SOCK_FAMILY  AF_BLUETOOTH
> #elif defined(CONFIG_NET_USRSOCK)
> #  define NETLIB_SOCK_FAMILY  AF_INET
> #elif defined(CONFIG_NET_NETLINK)
> #  define NETLIB_SOCK_FAMILY  AF_NETLINK
> #else
> #  define NETLIB_SOCK_FAMILY  AF_UNSPEC
> #endif
> 
> ]]]
> 
> More below...
> 
> On Sun, Jul 4, 2021 at 12:43 PM Alan Carvalho de Assis
> <ac...@gmail.com> wrote:
> >
> > Hi Murat,
> >
> > Just use the netnsh config and follow my video tutorial explaining how to
> > use USB Console.
> >
> > It is easy when you know which options to look at on menuconfig. It is
> > important to get used to menuconfig, otherwise it always will be like a
> > maze.
> 
> How to search for configs in the Kconfig files:
> 
> Option 1, interactively in the ncurses-based menuconfig program:
> Unless this depends on locale settings, the '/' (forward slash)
> character brings up a window where you can type in a config name to
> search for it; pay attention to the NOTE below...
> 
> Option 2, grep for these identifiers through the Kconfig files
> themselves. Note that these files are located in various places
> throughout the NuttX and apps trees, so you need to search recursively
> using your favorite grepping tool.
> 
> NOTE: If a config option is called CONFIG_FOO_BAR in source code, it
> is called FOO_BAR in Kconfig, so omit the CONFIG_ prefix when
> searching. Alternately you can grep for search terms in the Kconfig
> files themselves.
> 
> Kconfig options often depend on other Kconfig options, so you need to
> verify that you have the dependencies. Option 1 is easiest for this,
> since the menuconfig program will show you the dependencies for an
> option when you search for it, or when you bring up the help about it.
> It will say "depends on" and list out all the dependencies, with their
> actual values. So if something doesn't even show up in the menus, look
> carefully at the dependencies shown by the program and determine which
> one(s) are not configured that should be configured.
> 
> Hope this helps,
> Nathan
> 

Re: Formal way of using Nuttx-Posix libraries

Posted by Nathan Hartman <ha...@gmail.com>.
> On Sunday, July 4, 2021, murat tologlu <mt...@hotmail.com> wrote:
> > > netlib_setifstatus.c: In function 'netlib_ifup':
> > > netlib_setifstatus.c:67:27: error: 'NETLIB_SOCK_TYPE' undeclared (first
> > use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
> > >    67 |                           NETLIB_SOCK_TYPE,
> > NETLIB_SOCK_PROTOCOL);
> > >       |                           ^~~~~~~~~~~~~~~~
> > >       |                           NETLIB_SOCK_FAMILY
> > > netlib_setifstatus.c:67:27: note: each undeclared identifier is reported
> > only once for each function it appears in

Note that this issue has been seen before. See:

https://github.com/apache/incubator-nuttx-apps/issues/375

NETLIB_SOCK_TYPE is defined in the incubator-nuttx-apps repository in
include/netutils/netlib.h and its definition depends on the following
Kconfigs:

[[[

/* Using the following definitions, the following socket() arguments should
 * provide a valid socket in all configurations:
 *
 *   ret = socket(NETLIB_SOCK_FAMILY, NETLIB_SOCK_TYPE,
 *                NETLIB_SOCK_PROTOCOL);
 */

/* The address family that we used to create the socket really does not
 * matter.  It should, however, be valid in the current configuration.
 */

#if defined(CONFIG_NET_IPv4)
#  define NETLIB_SOCK_FAMILY  AF_INET
#elif defined(CONFIG_NET_IPv6)
#  define NETLIB_SOCK_FAMILY  AF_INET6
#elif defined(CONFIG_NET_LOCAL)
#  define NETLIB_SOCK_FAMILY  AF_LOCAL
#elif defined(CONFIG_NET_PKT)
#  define NETLIB_SOCK_FAMILY  AF_PACKET
#elif defined(CONFIG_NET_CAN)
#  define NETLIB_SOCK_FAMILY  AF_CAN
#elif defined(CONFIG_NET_IEEE802154)
#  define NETLIB_SOCK_FAMILY  AF_IEEE802154
#elif defined(CONFIG_WIRELESS_PKTRADIO)
#  define NETLIB_SOCK_FAMILY  AF_PKTRADIO
#elif defined(CONFIG_NET_BLUETOOTH)
#  define NETLIB_SOCK_FAMILY  AF_BLUETOOTH
#elif defined(CONFIG_NET_USRSOCK)
#  define NETLIB_SOCK_FAMILY  AF_INET
#elif defined(CONFIG_NET_NETLINK)
#  define NETLIB_SOCK_FAMILY  AF_NETLINK
#else
#  define NETLIB_SOCK_FAMILY  AF_UNSPEC
#endif

]]]

More below...

On Sun, Jul 4, 2021 at 12:43 PM Alan Carvalho de Assis
<ac...@gmail.com> wrote:
>
> Hi Murat,
>
> Just use the netnsh config and follow my video tutorial explaining how to
> use USB Console.
>
> It is easy when you know which options to look at on menuconfig. It is
> important to get used to menuconfig, otherwise it always will be like a
> maze.

How to search for configs in the Kconfig files:

Option 1, interactively in the ncurses-based menuconfig program:
Unless this depends on locale settings, the '/' (forward slash)
character brings up a window where you can type in a config name to
search for it; pay attention to the NOTE below...

Option 2, grep for these identifiers through the Kconfig files
themselves. Note that these files are located in various places
throughout the NuttX and apps trees, so you need to search recursively
using your favorite grepping tool.

NOTE: If a config option is called CONFIG_FOO_BAR in source code, it
is called FOO_BAR in Kconfig, so omit the CONFIG_ prefix when
searching. Alternately you can grep for search terms in the Kconfig
files themselves.

Kconfig options often depend on other Kconfig options, so you need to
verify that you have the dependencies. Option 1 is easiest for this,
since the menuconfig program will show you the dependencies for an
option when you search for it, or when you bring up the help about it.
It will say "depends on" and list out all the dependencies, with their
actual values. So if something doesn't even show up in the menus, look
carefully at the dependencies shown by the program and determine which
one(s) are not configured that should be configured.

Hope this helps,
Nathan

Re: Formal way of using Nuttx-Posix libraries

Posted by murat tologlu <mt...@hotmail.com>.
Hi Alan, I did. 
This way I could compile and run my code on Nuttx but I now get "Socketpair creation error" from my program. 
As far as I know socketpair fucnction was includded in Nuttx 10.1 but I can't see its reference in the  latest Network documentation here: https://nuttx.apache.org/docs/latest/reference/user/11_network.html
Anyway, I got some progress.

On 2021/07/04 16:43:05, Alan Carvalho de Assis <ac...@gmail.com> wrote: 
> Hi Murat,
> 
> Just use the netnsh config and follow my video tutorial explaining how to
> use USB Console.
> 
> It is easy when you know which options to look at on menuconfig. It is
> important to get used to menuconfig, otherwise it always will be like a
> maze.
> 
> BR,
> 
> Alan
> 
> On Sunday, July 4, 2021, murat tologlu <mt...@hotmail.com> wrote:
> 
> > I wish there was an easier way to configure the Nuttx; it is really hard!
> >
> > The application I wrote with the :netnsh configuration was compiled
> > without any problems. However I want to use /dev/ttyUSBx as >nsh console.
> > I'm trying to compare nsh and netnsh .config files to do something, but
> > it's really complicated.
> >
> > How can I go further .. :(
> >
> > On 2021/07/03 19:18:47, murat tologlu <mt...@hotmail.com> wrote:
> > > Hi Alan,
> > >
> > > Good advise the previous problem resolved after enabling the network but
> > now I get :
> > >
> > > ...
> > > netlib_setifstatus.c: In function 'netlib_ifup':
> > > netlib_setifstatus.c:67:27: error: 'NETLIB_SOCK_TYPE' undeclared (first
> > use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
> > >    67 |                           NETLIB_SOCK_TYPE,
> > NETLIB_SOCK_PROTOCOL);
> > >       |                           ^~~~~~~~~~~~~~~~
> > >       |                           NETLIB_SOCK_FAMILY
> > > netlib_setifstatus.c:67:27: note: each undeclared identifier is reported
> > only once for each function it appears in
> > > netlib_setifstatus.c: In function 'netlib_ifdown':
> > > netlib_setifstatus.c:111:27: error: 'NETLIB_SOCK_TYPE' undeclared (first
> > use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
> > >   111 |                           NETLIB_SOCK_TYPE,
> > NETLIB_SOCK_PROTOCOL);
> > >       |                           ^~~~~~~~~~~~~~~~
> > >       |                           NETLIB_SOCK_FAMILY
> > > /home/murat/nuttxspace/apps/Application.mk:134: recipe for target
> > 'netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o' failed
> > > make[3]: *** [netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o]
> > Error 1
> > > make[3]: Leaving directory '/home/murat/nuttxspace/apps/netutils/netlib'
> > > Makefile:42: recipe for target '/home/murat/nuttxspace/apps/netutils/netlib_all'
> > failed
> > > make[2]: *** [/home/murat/nuttxspace/apps/netutils/netlib_all] Error 2
> > > make[2]: Leaving directory '/home/murat/nuttxspace/apps'
> > > Makefile:35: recipe for target 'all' failed
> > > make[1]: *** [all] Error 2
> > > make[1]: Leaving directory '/home/murat/nuttxspace/apps'
> > > tools/LibTargets.mk:210: recipe for target '/home/murat/nuttxspace/apps/libapps.a'
> > failed
> > > make: *** [/home/murat/nuttxspace/apps/libapps.a] Error 2
> > >
> > >
> > > On 2021/07/03 10:45:40, Alan Carvalho de Assis <ac...@gmail.com>
> > wrote:
> > > > Hi Murat,
> > > >
> > > > Did you enable Network support in the menuconfig?
> > > >
> > > > Normally when some function is not found it means some feature in the
> > > > menuconfig is not enabled.
> > > >
> > > > BR,
> > > >
> > > > Alan
> > > >
> > > > On 7/3/21, murat tologlu <mt...@hotmail.com> wrote:
> > > > > Hi,
> > > > >
> > > > > I am doing experiments of porting standard posix applications to
> > Nuttx, I
> > > > > try to run same applications on both Ubuntu and Nuttx.  In one
> > application I
> > > > > needed to use socket.h, I did "#include <sys/socket.h>" in my c file
> > but it
> > > > > seems that the linker doesn't find the library, I get "undefined
> > reference
> > > > > to `socketpair' 'send' 'recv' errors while all of them clearly
> > defined in
> > > > > sys/socket.h !
> > > > >
> > > > > Of-course I can modify the c file, Makefile, I can move or copy
> > library
> > > > > files to appropriate locations to resolve the problem, but I would
> > like to
> > > > > learn the formal (preferred) way of resolving this issue on Nuttx
> > > > >  because the same code compiles and runs on Ubuntu without any
> > modification
> > > > > other than removing <nuttx/config.h>.
> > > > >
> > > > > BR
> > > > > Murat
> > > > >
> > > >
> > >
> >
> 

Re: Formal way of using Nuttx-Posix libraries

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Murat,

Just use the netnsh config and follow my video tutorial explaining how to
use USB Console.

It is easy when you know which options to look at on menuconfig. It is
important to get used to menuconfig, otherwise it always will be like a
maze.

BR,

Alan

On Sunday, July 4, 2021, murat tologlu <mt...@hotmail.com> wrote:

> I wish there was an easier way to configure the Nuttx; it is really hard!
>
> The application I wrote with the :netnsh configuration was compiled
> without any problems. However I want to use /dev/ttyUSBx as >nsh console.
> I'm trying to compare nsh and netnsh .config files to do something, but
> it's really complicated.
>
> How can I go further .. :(
>
> On 2021/07/03 19:18:47, murat tologlu <mt...@hotmail.com> wrote:
> > Hi Alan,
> >
> > Good advise the previous problem resolved after enabling the network but
> now I get :
> >
> > ...
> > netlib_setifstatus.c: In function 'netlib_ifup':
> > netlib_setifstatus.c:67:27: error: 'NETLIB_SOCK_TYPE' undeclared (first
> use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
> >    67 |                           NETLIB_SOCK_TYPE,
> NETLIB_SOCK_PROTOCOL);
> >       |                           ^~~~~~~~~~~~~~~~
> >       |                           NETLIB_SOCK_FAMILY
> > netlib_setifstatus.c:67:27: note: each undeclared identifier is reported
> only once for each function it appears in
> > netlib_setifstatus.c: In function 'netlib_ifdown':
> > netlib_setifstatus.c:111:27: error: 'NETLIB_SOCK_TYPE' undeclared (first
> use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
> >   111 |                           NETLIB_SOCK_TYPE,
> NETLIB_SOCK_PROTOCOL);
> >       |                           ^~~~~~~~~~~~~~~~
> >       |                           NETLIB_SOCK_FAMILY
> > /home/murat/nuttxspace/apps/Application.mk:134: recipe for target
> 'netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o' failed
> > make[3]: *** [netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o]
> Error 1
> > make[3]: Leaving directory '/home/murat/nuttxspace/apps/netutils/netlib'
> > Makefile:42: recipe for target '/home/murat/nuttxspace/apps/netutils/netlib_all'
> failed
> > make[2]: *** [/home/murat/nuttxspace/apps/netutils/netlib_all] Error 2
> > make[2]: Leaving directory '/home/murat/nuttxspace/apps'
> > Makefile:35: recipe for target 'all' failed
> > make[1]: *** [all] Error 2
> > make[1]: Leaving directory '/home/murat/nuttxspace/apps'
> > tools/LibTargets.mk:210: recipe for target '/home/murat/nuttxspace/apps/libapps.a'
> failed
> > make: *** [/home/murat/nuttxspace/apps/libapps.a] Error 2
> >
> >
> > On 2021/07/03 10:45:40, Alan Carvalho de Assis <ac...@gmail.com>
> wrote:
> > > Hi Murat,
> > >
> > > Did you enable Network support in the menuconfig?
> > >
> > > Normally when some function is not found it means some feature in the
> > > menuconfig is not enabled.
> > >
> > > BR,
> > >
> > > Alan
> > >
> > > On 7/3/21, murat tologlu <mt...@hotmail.com> wrote:
> > > > Hi,
> > > >
> > > > I am doing experiments of porting standard posix applications to
> Nuttx, I
> > > > try to run same applications on both Ubuntu and Nuttx.  In one
> application I
> > > > needed to use socket.h, I did "#include <sys/socket.h>" in my c file
> but it
> > > > seems that the linker doesn't find the library, I get "undefined
> reference
> > > > to `socketpair' 'send' 'recv' errors while all of them clearly
> defined in
> > > > sys/socket.h !
> > > >
> > > > Of-course I can modify the c file, Makefile, I can move or copy
> library
> > > > files to appropriate locations to resolve the problem, but I would
> like to
> > > > learn the formal (preferred) way of resolving this issue on Nuttx
> > > >  because the same code compiles and runs on Ubuntu without any
> modification
> > > > other than removing <nuttx/config.h>.
> > > >
> > > > BR
> > > > Murat
> > > >
> > >
> >
>

Re: Formal way of using Nuttx-Posix libraries

Posted by murat tologlu <mt...@hotmail.com>.
I wish there was an easier way to configure the Nuttx; it is really hard! 

The application I wrote with the :netnsh configuration was compiled without any problems. However I want to use /dev/ttyUSBx as >nsh console. I'm trying to compare nsh and netnsh .config files to do something, but it's really complicated. 

How can I go further .. :(

On 2021/07/03 19:18:47, murat tologlu <mt...@hotmail.com> wrote: 
> Hi Alan,
> 
> Good advise the previous problem resolved after enabling the network but now I get :
> 
> ...
> netlib_setifstatus.c: In function 'netlib_ifup':
> netlib_setifstatus.c:67:27: error: 'NETLIB_SOCK_TYPE' undeclared (first use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
>    67 |                           NETLIB_SOCK_TYPE, NETLIB_SOCK_PROTOCOL);
>       |                           ^~~~~~~~~~~~~~~~
>       |                           NETLIB_SOCK_FAMILY
> netlib_setifstatus.c:67:27: note: each undeclared identifier is reported only once for each function it appears in
> netlib_setifstatus.c: In function 'netlib_ifdown':
> netlib_setifstatus.c:111:27: error: 'NETLIB_SOCK_TYPE' undeclared (first use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
>   111 |                           NETLIB_SOCK_TYPE, NETLIB_SOCK_PROTOCOL);
>       |                           ^~~~~~~~~~~~~~~~
>       |                           NETLIB_SOCK_FAMILY
> /home/murat/nuttxspace/apps/Application.mk:134: recipe for target 'netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o' failed
> make[3]: *** [netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o] Error 1
> make[3]: Leaving directory '/home/murat/nuttxspace/apps/netutils/netlib'
> Makefile:42: recipe for target '/home/murat/nuttxspace/apps/netutils/netlib_all' failed
> make[2]: *** [/home/murat/nuttxspace/apps/netutils/netlib_all] Error 2
> make[2]: Leaving directory '/home/murat/nuttxspace/apps'
> Makefile:35: recipe for target 'all' failed
> make[1]: *** [all] Error 2
> make[1]: Leaving directory '/home/murat/nuttxspace/apps'
> tools/LibTargets.mk:210: recipe for target '/home/murat/nuttxspace/apps/libapps.a' failed
> make: *** [/home/murat/nuttxspace/apps/libapps.a] Error 2
> 
> 
> On 2021/07/03 10:45:40, Alan Carvalho de Assis <ac...@gmail.com> wrote: 
> > Hi Murat,
> > 
> > Did you enable Network support in the menuconfig?
> > 
> > Normally when some function is not found it means some feature in the
> > menuconfig is not enabled.
> > 
> > BR,
> > 
> > Alan
> > 
> > On 7/3/21, murat tologlu <mt...@hotmail.com> wrote:
> > > Hi,
> > >
> > > I am doing experiments of porting standard posix applications to Nuttx, I
> > > try to run same applications on both Ubuntu and Nuttx.  In one application I
> > > needed to use socket.h, I did "#include <sys/socket.h>" in my c file but it
> > > seems that the linker doesn't find the library, I get "undefined reference
> > > to `socketpair' 'send' 'recv' errors while all of them clearly defined in
> > > sys/socket.h !
> > >
> > > Of-course I can modify the c file, Makefile, I can move or copy library
> > > files to appropriate locations to resolve the problem, but I would like to
> > > learn the formal (preferred) way of resolving this issue on Nuttx
> > >  because the same code compiles and runs on Ubuntu without any modification
> > > other than removing <nuttx/config.h>.
> > >
> > > BR
> > > Murat
> > >
> > 
> 

Re: Formal way of using Nuttx-Posix libraries

Posted by murat tologlu <mt...@hotmail.com>.
Hi Alan,

Good advise the previous problem resolved after enabling the network but now I get :

...
netlib_setifstatus.c: In function 'netlib_ifup':
netlib_setifstatus.c:67:27: error: 'NETLIB_SOCK_TYPE' undeclared (first use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
   67 |                           NETLIB_SOCK_TYPE, NETLIB_SOCK_PROTOCOL);
      |                           ^~~~~~~~~~~~~~~~
      |                           NETLIB_SOCK_FAMILY
netlib_setifstatus.c:67:27: note: each undeclared identifier is reported only once for each function it appears in
netlib_setifstatus.c: In function 'netlib_ifdown':
netlib_setifstatus.c:111:27: error: 'NETLIB_SOCK_TYPE' undeclared (first use in this function); did you mean 'NETLIB_SOCK_FAMILY'?
  111 |                           NETLIB_SOCK_TYPE, NETLIB_SOCK_PROTOCOL);
      |                           ^~~~~~~~~~~~~~~~
      |                           NETLIB_SOCK_FAMILY
/home/murat/nuttxspace/apps/Application.mk:134: recipe for target 'netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o' failed
make[3]: *** [netlib_setifstatus.home.murat.nuttxspace.apps.netutils.netlib.o] Error 1
make[3]: Leaving directory '/home/murat/nuttxspace/apps/netutils/netlib'
Makefile:42: recipe for target '/home/murat/nuttxspace/apps/netutils/netlib_all' failed
make[2]: *** [/home/murat/nuttxspace/apps/netutils/netlib_all] Error 2
make[2]: Leaving directory '/home/murat/nuttxspace/apps'
Makefile:35: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/murat/nuttxspace/apps'
tools/LibTargets.mk:210: recipe for target '/home/murat/nuttxspace/apps/libapps.a' failed
make: *** [/home/murat/nuttxspace/apps/libapps.a] Error 2


On 2021/07/03 10:45:40, Alan Carvalho de Assis <ac...@gmail.com> wrote: 
> Hi Murat,
> 
> Did you enable Network support in the menuconfig?
> 
> Normally when some function is not found it means some feature in the
> menuconfig is not enabled.
> 
> BR,
> 
> Alan
> 
> On 7/3/21, murat tologlu <mt...@hotmail.com> wrote:
> > Hi,
> >
> > I am doing experiments of porting standard posix applications to Nuttx, I
> > try to run same applications on both Ubuntu and Nuttx.  In one application I
> > needed to use socket.h, I did "#include <sys/socket.h>" in my c file but it
> > seems that the linker doesn't find the library, I get "undefined reference
> > to `socketpair' 'send' 'recv' errors while all of them clearly defined in
> > sys/socket.h !
> >
> > Of-course I can modify the c file, Makefile, I can move or copy library
> > files to appropriate locations to resolve the problem, but I would like to
> > learn the formal (preferred) way of resolving this issue on Nuttx
> >  because the same code compiles and runs on Ubuntu without any modification
> > other than removing <nuttx/config.h>.
> >
> > BR
> > Murat
> >
> 

Re: Formal way of using Nuttx-Posix libraries

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Murat,

Did you enable Network support in the menuconfig?

Normally when some function is not found it means some feature in the
menuconfig is not enabled.

BR,

Alan

On 7/3/21, murat tologlu <mt...@hotmail.com> wrote:
> Hi,
>
> I am doing experiments of porting standard posix applications to Nuttx, I
> try to run same applications on both Ubuntu and Nuttx.  In one application I
> needed to use socket.h, I did "#include <sys/socket.h>" in my c file but it
> seems that the linker doesn't find the library, I get "undefined reference
> to `socketpair' 'send' 'recv' errors while all of them clearly defined in
> sys/socket.h !
>
> Of-course I can modify the c file, Makefile, I can move or copy library
> files to appropriate locations to resolve the problem, but I would like to
> learn the formal (preferred) way of resolving this issue on Nuttx
>  because the same code compiles and runs on Ubuntu without any modification
> other than removing <nuttx/config.h>.
>
> BR
> Murat
>