C++ Compile error on NetBSD '::system' has not been declared

Klaatu von Schlacker

I have some C++ code that compiles nicely on Linux but so far I'm having trouble getting it to compile correctly on NetBSD.

These are my includes:

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <iomanip>
#include <boost/regex.hpp>

I compile with this command:

g++ -v -O2 -fno-strict-aliasing -I /usr/pkg/include \
barefoot.cpp -o barefoot -L /usr/pkg/lib/ -lboost_regex \
-L /usr/pkg/lib/ -lboost_regex -lpthreads

Which renders this output:

Using built-in specs.
COLLECT_GCC=g++
Target: x86_64--netbsd

Configured with: /usr/src2/tools/gcc/../../external/gpl3/gcc/dist/configure --target=x86_64--netbsd --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20111202' --enable-__cxa_atexit --with-tune=nocona --with-mpc=/var/obj/mknative/amd64/usr/src2/destdir.amd64/usr --with-mpfr=/var/obj/mknative/amd64/usr/src2/destdir.amd64/usr --with-gmp=/var/obj/mknative/amd64/usr/src2/destdir.amd64/usr --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd5.99.56 --host=x86_64--netbsd

Thread model: posix

gcc version 4.5.3 (NetBSD nb2 20110806) 
COLLECT_GCC_OPTIONS='-v' '-O2' '-fno-strict-aliasing' '-I' '/usr/pkg/include/' '-o' 'a.out' '-L' '/usr/pkg/lib/' '-mtune=nocona' '-march=x86-64'
 /usr/libexec/cc1plus -quiet -v -I /usr/pkg/include/ barefoot.cpp -quiet -dumpbase barefoot.cpp -mtune=nocona -march=x86-64 -auxbase barefoot -O2 -version -fno-strict-aliasing -o /var/tmp//cc9Dcmwi.s
GNU C++ (NetBSD nb2 20110806) version 4.5.3 (x86_64--netbsd)
        compiled by GNU C version 4.5.3, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.9

GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131007
#include "..." search starts here:
#include <...> search starts here:
 /usr/pkg/include/
 /usr/include/g++
 /usr/include/g++/backward
 /usr/include/gcc-4.5
 /usr/include
End of search list.

GNU C++ (NetBSD nb2 20110806) version 4.5.3 (x86_64--netbsd)
        compiled by GNU C version 4.5.3, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131007
Compiler executable checksum: a34e7d170f4dd8d4687d2b62e8dca4b7
In file included from /usr/include/g++/bits/gthr.h:166:0,
                 from /usr/include/g++/ext/atomicity.h:34,
                 from /usr/include/g++/bits/ios_base.h:41,
                 from /usr/include/g++/ios:43,
                 from /usr/include/g++/istream:40,
                 from /usr/include/g++/fstream:40,
                 from barefoot.cpp:29:
/usr/include/g++/bits/gthr-default.h:130:9: error: 'pthread_detach' was not declared in this scope
/usr/include/g++/bits/gthr-default.h:130:1: error: invalid type in declaration before ';' token
/usr/include/g++/bits/gthr-default.h: In function 'int __gthread_detach(pthread_st*)':
/usr/include/g++/bits/gthr-default.h:668:46: error: '__gthrw_pthread_detach' cannot be used as a function
In file included from /usr/pkg/include/boost/regex/v4/regex_workaround.hpp:25:0,
                 from /usr/pkg/include/boost/regex/v4/regex.hpp:32,
                 from /usr/pkg/include/boost/regex.hpp:31,
                 from barefoot.cpp:32:
/usr/include/g++/cstdlib: At global scope:
/usr/include/g++/cstdlib:132:11: error: '::system' has not been declared

I tried adding -lpthread, but that resulted in the same output. Not sure what to try next.

jxh

I do not know exactly why you are facing this problem, but I can provide you with some next steps to try.

  • Notice that the first error is that pthread_detach is missing. The system header files will typically make sure whatever headers they need are included, but you can try adding <pthread.h> above all the other headers.

  • If that fails, you need to figure out which file got included as a result of adding #include <pthread.h>, and make sure pthread_detach is present inside it (it really should be there somewhere).

  • Assuming it is there, there must be some conditional compilation that is causing it to not be visible to your source code. Find the conditional guards, and what macro values affect it.

  • Then, you will need to see why your system is defining the macro values in a way that causes the function pthread_detach to not be visible.

With this investigation, you may discover that you are not including the right <pthread.h> file. This may be due to system include directories conflicting with the include directories you want to use.

This answer (it is towards the bottom) to this question shows how to display the predefined macros for the g++ compiler.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

C++, error: '__locale_t' has not been declared

From Dev

C++ make error: object_var has not been declared

From Dev

error: 'ios_base' has not been declared

From Dev

silly C++ syntax has not been declared

From Dev

Undeclared variable in C while it has been declared

From Dev

g++10, C++20, boost 1.75.0 :: error: 'awaitable' has not been declared in 'boost::asio'

From Dev

Bool has not been declared

From Dev

Namespace has not been declared

From Dev

Member "has already been declared" error with CUDA and Eigen

From Dev

"Error: '::hypot' has not been declared" in cmath while trying to embed Python

From Dev

build insert statement error Https has already been declared

From Dev

ERROR: 'Namespace for prefix 'xsi' has not been declared.'

From Dev

The field was declared on serializer , but has not been included error in django rest

From Dev

When the destroy() has been declared?

From Dev

When the destroy() has been declared?

From Dev

Android compile error; Java plugin has been applied, not compatible with android

From Dev

System error. The error has been logged and we will investigate

From Dev

Debian Jessie 8.9 Compiling Error for Cryptocoin Wallets "error: ‘::SSLv3_server_method’ has not been declared"

From Dev

c++ compile error building arduino project: variable not declared in this scope

From Dev

c++ compile error building arduino project: variable not declared in this scope

From Dev

C++ '<class name> has not been declared' and '<class name> has no field <field name>' errors

From Dev

How to import a C function into C++ project that has not been declared in a C header?

From Dev

Error: system file has been modified since precompiled header was built

From Dev

CreateObject randomly throws "A system shutdown has already been scheduled" error

From Dev

::write() and ::read() has not been declared error. Qt5 UNIX signal handling

From Dev

GCC does not throw an error during the compiler stage when a function has not been forward declared

From Dev

Browser: Identifier X has already been declared

From Dev

boost:asio ::UnregisterWaitEx has not been declared

From Dev

Assigning a variable to a textBox once it has been declared

Related Related

  1. 1

    C++, error: '__locale_t' has not been declared

  2. 2

    C++ make error: object_var has not been declared

  3. 3

    error: 'ios_base' has not been declared

  4. 4

    silly C++ syntax has not been declared

  5. 5

    Undeclared variable in C while it has been declared

  6. 6

    g++10, C++20, boost 1.75.0 :: error: 'awaitable' has not been declared in 'boost::asio'

  7. 7

    Bool has not been declared

  8. 8

    Namespace has not been declared

  9. 9

    Member "has already been declared" error with CUDA and Eigen

  10. 10

    "Error: '::hypot' has not been declared" in cmath while trying to embed Python

  11. 11

    build insert statement error Https has already been declared

  12. 12

    ERROR: 'Namespace for prefix 'xsi' has not been declared.'

  13. 13

    The field was declared on serializer , but has not been included error in django rest

  14. 14

    When the destroy() has been declared?

  15. 15

    When the destroy() has been declared?

  16. 16

    Android compile error; Java plugin has been applied, not compatible with android

  17. 17

    System error. The error has been logged and we will investigate

  18. 18

    Debian Jessie 8.9 Compiling Error for Cryptocoin Wallets "error: ‘::SSLv3_server_method’ has not been declared"

  19. 19

    c++ compile error building arduino project: variable not declared in this scope

  20. 20

    c++ compile error building arduino project: variable not declared in this scope

  21. 21

    C++ '<class name> has not been declared' and '<class name> has no field <field name>' errors

  22. 22

    How to import a C function into C++ project that has not been declared in a C header?

  23. 23

    Error: system file has been modified since precompiled header was built

  24. 24

    CreateObject randomly throws "A system shutdown has already been scheduled" error

  25. 25

    ::write() and ::read() has not been declared error. Qt5 UNIX signal handling

  26. 26

    GCC does not throw an error during the compiler stage when a function has not been forward declared

  27. 27

    Browser: Identifier X has already been declared

  28. 28

    boost:asio ::UnregisterWaitEx has not been declared

  29. 29

    Assigning a variable to a textBox once it has been declared

HotTag

Archive