error: stray ‘\224’ in program after including external library - c++

I'm new to C++. I'm trying to use the libserial
bitmap_test.cpp
#include <SerialStream.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace LibSerial ;
int main()
{
SerialStream serial_port( "/dev/ttyS0" ) ;
return 0;
}
The error:
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:520: error: null character(s) ignored [-Werror]
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:1: error: stray ‘\17’ in program
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:525: error: null character(s) ignored [-Werror]
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:1: error: stray ‘\231’ in program
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:529: error: null character(s) ignored [-Werror]
/usr/local/lib/libserial.a:118:532: error: null character(s) ignored [-Werror]
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:1: error: stray ‘\10’ in program
/usr/local/lib/libserial.a:118:1: error: stray ‘\34’ in program
...
The makefile
COMPILER = -c++
OPTIONS = -ansi -pedantic-errors -Wall -Wall -Werror -Wextra -o
LINKER_OPT = -L/usr/lib -lserial -include/usr/local/lib/libserial.a -lstdc++ -lm
all: bitmap_test
bitmap_test: bitmap_test.cpp bitmap_image.hpp
$(COMPILER) $(OPTIONS) bitmap_test bitmap_test.cpp $(LINKER_OPT)
I did research and understand it's a problem with encoding but don't know how to fix it.
Any help is much appreciated.
EDIT:
The library is in the right path:
/sbin/ldconfig -p | grep libserial
libserial.so.0 (libc6,x86-64) => /usr/local/lib/libserial.so.0
libserial.so.0 (libc6,x86-64) => /usr/lib/libserial.so.0
libserial.so (libc6,x86-64) => /usr/local/lib/libserial.so
libserial.so (libc6,x86-64) => /usr/lib/libserial.so
But if I change the Makefile as suggested, I will have this problem:
c++ -ansi -pedantic-errors -Wall -Wall -Werror -Wextra -o bitmap_test bitmap_test.cpp -L/usr/local/lib -lstdc++ -lm -lserial
bitmap_test.cpp: In function ‘int main()’:
bitmap_test.cpp:32:40: error: call of overloaded ‘SerialStream(const char [11])’ is ambiguous
SerialStream serial_port( "/dev/ttyS0" ) ;
^
bitmap_test.cpp:32:40: note: candidates are:
In file included from bitmap_test.cpp:19:0:
/usr/local/include/SerialStream.h:98:13: note: LibSerial::SerialStream::SerialStream(std::string, LibSerial::SerialStreamBuf::BaudRateEnum, LibSerial::SerialStreamBuf::CharSizeEnum, LibSerial::SerialStreamBuf::ParityEnum, short int, LibSerial::SerialStreamBuf::FlowControlEnum)
SerialStream( const std::string fileName,
^
/usr/local/include/SerialStream.h:84:22: note: LibSerial::SerialStream::SerialStream(std::string, std::ios_base::openmode)
explicit SerialStream( const std::string fileName,
^
make: [bitmap_test] Error 1 (ignored)

Stray characters usually has to do with the source encoding.
The “null character(s) ignored” diagnostic would generally indicate that the source code is UTF-16 or UTF-32.
However, the makefile shows that you're treating a static library as a forced include file:
-include/usr/local/lib/libserial.a
With my g++ in Windows:
> g++ -v --help 2>&1 | find "-include "
--include This switch lacks documentation
-include <file> Include the contents of <file> before other

Related

Cmake Error during gtest compilation - gtest/internal/gtest-type-util.h:732:25: error: expected type-specifier

I am facing an error while I am trying to build my project using cmake.
I manually downloaded and install gtest on my pc (i.e. gtest header files are available in /usr/include) and libs such as gtest, gtest_main in /usr/lib)
Below is the code of my projects main function. (lte_softmodem_test.cpp)
#include <gtest/gtest.h>
#include <iostream>
using namespace std;
TEST(sample, sample2){
}
int main(int argc, char **argv)
{
cout << "This is test" << endl;
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
return 0;
}
When I compiled this file separately using the below command, it is working!!
g++ eNB_scheduler_test.cpp -L /usr/lib/ -lgtest -lgtest_main -pthread -std=c++11
But, when I tried to include this in my projects CMake file, it is showing me an error.
CMake file: (CMake file is a bit large, so I have just included few lines where I am trying to compile this file)
# lte-softmodem is both eNB and UE implementation
###################################################
add_executable(lte-softmodem
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-enb.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR_TARGETS}/RT/USER/ru_control.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem_test.cpp
${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c
${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR_TARGETS}/COMMON/create_tasks.c
${OPENAIR_TARGETS}/COMMON/create_tasks_mbms.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR2_DIR}/RRC/NAS/rb_config.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${GTPU_need_ITTI}
${XFORMSINTERFACE_SOURCE}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag)
target_link_libraries (lte-softmodem
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl gtest gtest-main -lpthread)
CMake Output in verbose mode while compiling the file lte_softmodem_test.cpp:
/usr/bin/c++ -DASN1_MINIMUM_VERSION=924
-DCMAKE_BUILD_TYPE="RelWithDebInfo" -DDRIVER2013 -DENABLE_ITTI -DENABLE_NAS_UE_LOGGING -DENABLE_USE_CPU_EXECUTION_TIME -DENABLE_USE_MME -DENABLE_VCD -DENB_MODE -DEXMIMO_IOT -DF1AP_RELEASE=R15 -DF1AP_VERSION=3873 -DFIRMWARE_VERSION=""No svn information"" -DFLPT_VERSION=V2 -DFSPT_VERSION=V2 -DJUMBO_FRAME
-DLTE_RRC_VERSION=3696 -DM2AP_RELEASE=R14 -DM2AP_VERSION=3584 -DM3AP_RELEASE=R14 -DM3AP_VERSION=3584 -DMAX_NUM_CCs=1 -DNAS_BUILT_IN_UE -DNAS_UE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=4 -DNETTLE_VERSION_MAJOR=3 -DNETTLE_VERSION_MINOR=2 -DNO_RRM -DNUMBER_OF_UE_MAX_NB_IoT=16 -DNone=1 -DOAI_NW_DRIVER_USE_NETLINK -DOPENAIR2 -DOPENAIR_LTE -DPACKAGE_BUGREPORT="openair4g-devel#lists.eurecom.fr" -DPACKAGE_NAME="" -DPACKAGE_VERSION=""Branch: master Abrev. Hash: 9a06ceb Date: Wed Sep 9 16:15:50 2020 +0200"" -DPHYSIM -DPHY_CONTEXT
-DRel14=1 -DS1AP_RELEASE=R14 -DS1AP_VERSION=3664 -DTRACE_RLC_MUTEX -DT_TRACER -DX2AP_RELEASE=R14 -DX2AP_VERSION=3680 -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/RRC_Rel14
-I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/S1AP_R14
-I/root/openairinterface5g/openair3/S1AP -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/M2AP_R14
-I/root/openairinterface5g/openair2/M2AP -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/M3AP_R14
-I/root/openairinterface5g/openair3/M3AP -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/X2AP_R14
-I/root/openairinterface5g/openair2/X2AP -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/F1AP_R15.2.1
-I/root/openairinterface5g/openair2/F1AP -I/root/openairinterface5g/targets/ARCH/USRP/USERSPACE/LIB -I/root/openairinterface5g/targets/ARCH/BLADERF/USERSPACE/LIB -I/root/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB -I/root/openairinterface5g/targets/ARCH/ETHERNET/USERSPACE/LIB -I/root/openairinterface5g/targets/ARCH/IRIS/USERSPACE/LIB -I/root/openairinterface5g/targets/ARCH/COMMON -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles
-I/root/openairinterface5g/openair2/COMMON -I/root/openairinterface5g/openair2/UTIL -I/root/openairinterface5g/openair2/UTIL/LOG -I/root/openairinterface5g/openair3/COMMON -I/root/openairinterface5g/openair3/UTILS -I/root/openairinterface5g/nfapi/open-nFAPI/nfapi/public_inc -I/root/openairinterface5g/nfapi/open-nFAPI/common/public_inc -I/root/openairinterface5g/nfapi/open-nFAPI/pnf/public_inc -I/root/openairinterface5g/nfapi/open-nFAPI/nfapi/inc -I/root/openairinterface5g/nfapi/open-nFAPI/sim_common/inc -I/root/openairinterface5g/nfapi/open-nFAPI/pnf_sim/inc -I/root/openairinterface5g/openair1 -I/root/openairinterface5g/openair2 -I/root/openairinterface5g/openair3/NAS/TOOLS -I/root/openairinterface5g/openair2/ENB_APP -I/root/openairinterface5g/openair2/MCE_APP -I/root/openairinterface5g/openair2/LAYER2/RLC -I/root/openairinterface5g/openair2/LAYER2/RLC/AM_v9.3.0 -I/root/openairinterface5g/openair2/LAYER2/RLC/UM_v9.3.0 -I/root/openairinterface5g/openair2/LAYER2/RLC/TM_v9.3.0 -I/root/openairinterface5g/openair2/LAYER2/PDCP_v10.1.0 -I/root/openairinterface5g/openair2/RRC/LTE/MESSAGES -I/root/openairinterface5g/openair2/RRC/LTE -I/root/openairinterface5g/common/utils -I/root/openairinterface5g/common/utils/ocp_itti -I/root/openairinterface5g/openair3/NAS/COMMON -I/root/openairinterface5g/openair3/NAS/COMMON/API/NETWORK -I/root/openairinterface5g/openair3/NAS/COMMON/EMM/MSG -I/root/openairinterface5g/openair3/NAS/COMMON/ESM/MSG -I/root/openairinterface5g/openair3/NAS/UE/ESM -I/root/openairinterface5g/openair3/NAS/UE/EMM -I/root/openairinterface5g/openair3/NAS/UE/API/USER -I/root/openairinterface5g/openair3/NAS/COMMON/IES -I/root/openairinterface5g/openair3/NAS/COMMON/UTIL -I/root/openairinterface5g/openair3/SECU -I/root/openairinterface5g/openair3/SCTP -I/root/openairinterface5g/openair3/UDP -I/root/openairinterface5g/openair3/GTPV1-U -I/root/openairinterface5g/openair3/MME_APP -I/root/openairinterface5g/targets/COMMON -I/root/openairinterface5g/openair2/ENB_APP/CONTROL_MODULES/PHY -I/root/openairinterface5g/openair2/ENB_APP/CONTROL_MODULES/MAC -I/root/openairinterface5g/openair2/ENB_APP/CONTROL_MODULES/RRC -I/root/openairinterface5g/openair2/ENB_APP/CONTROL_MODULES/PDCP -I/root/openairinterface5g/openair2/UTIL/OSA -I/root/openairinterface5g/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/inc
-I/root/openairinterface5g/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/inc
-I/root/openairinterface5g/openair2/LAYER2/PROTO_AGENT -I/root/openairinterface5g/openair2/UTIL/MEM -I/root/openairinterface5g/openair2/UTIL/LISTS -I/root/openairinterface5g/openair2/UTIL/FIFO -I/root/openairinterface5g/openair2/UTIL/OCG -I/root/openairinterface5g/openair2/UTIL/MATH -I/root/openairinterface5g/openair2/UTIL/TIMER -I/root/openairinterface5g/openair2/UTIL/OMG -I/root/openairinterface5g/openair2/UTIL/OTG -I/root/openairinterface5g/openair2/UTIL/CLI -I/root/openairinterface5g/openair2/UTIL/OPT -I/root/openairinterface5g/openair2/UTIL/OMV -I/root/openairinterface5g/openair3/GTPV1-U/nw-gtpv1u/shared -I/root/openairinterface5g/openair3/GTPV1-U/nw-gtpv1u/include -I/root/openairinterface5g -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/FLPT_V2
-I/root/openairinterface5g/openair2/UTIL/ASYNC_IF -I/root/openairinterface5g/cmake_targets/lte_build_oai/build/CMakeFiles/FSPT_V2
-I/root/openairinterface5g/common/utils/hashtable -I/root/openairinterface5g/common/utils/msc -I/root/openairinterface5g/nfapi/open-nFAPI/pnf/inc -I/root/openairinterface5g/nfapi/open-nFAPI/vnf/public_inc -I/root/openairinterface5g/nfapi/open-nFAPI/vnf/inc -I/root/openairinterface5g/nfapi/oai_integration -I/root/openairinterface5g/openair3/NAS/UE -I/root/openairinterface5g/openair3/NAS/UE/API/USIM -I/root/openairinterface5g/openair3/NAS/UE/EMM/SAP -I/root/openairinterface5g/openair3/NAS/UE/ESM/SAP -I/root/openairinterface5g/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src
-I/root/openairinterface5g/openair2/UTIL/LFDS/liblfds7.0.0/liblfds700/src
-I/usr/include/libxml2 -I/usr/include/atlas -I/root/openairinterface5g/common/utils/T -mavx2 -msse4.1 -mssse3 -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic -std=c++11 -D'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)' -O2 -g -DNDEBUG -o CMakeFiles/lte-softmodem.dir/root/openairinterface5g/targets/RT/USER/lte-softmodem_test.cpp.o
-c /root/openairinterface5g/targets/RT/USER/lte-softmodem_test.cpp
Error log:
<command-line>:0:6: error: expected identifier before numeric constant
<command-line>:0:6: error: expected unqualified-id before numeric constant
<command-line>:0:6: error: expected type-specifier before numeric constant
<command-line>:0:6: error: expected type-specifier before numeric constant
In file included from /usr/local/include/gtest/gtest.h:62:0,
from /root/openairinterface5g/targets/RT/USER/lte-softmodem_test.cpp:2:
/usr/local/include/gtest/internal/gtest-internal.h:690:39: error: variable or field ‘GenerateNamesRecursively’ declared void
void GenerateNamesRecursively(internal::None, std::vector<std::string>*, int) {}
^
<command-line>:0:6: error: expected unqualified-id before numeric constant
In file included from /usr/local/include/gtest/gtest.h:62:0,
from /root/openairinterface5g/targets/RT/USER/lte-softmodem_test.cpp:2:
/usr/local/include/gtest/internal/gtest-internal.h:690:71: error: expected primary-expression before ‘*’ token
void GenerateNamesRecursively(internal::None, std::vector<std::string>*, int) {}
^
/usr/local/include/gtest/internal/gtest-internal.h:690:72: error: expected primary-expression before ‘,’ token
void GenerateNamesRecursively(internal::None, std::vector<std::string>*, int) {}
^
/usr/local/include/gtest/internal/gtest-internal.h:690:74: error: expected primary-expression before ‘int’
void GenerateNamesRecursively(internal::None, std::vector<std::string>*, int) {}
^
/usr/local/include/gtest/internal/gtest-internal.h:757:61: error: template argument 3 is invalid
class TypeParameterizedTest<Fixture, TestSel, internal::None> {
^
/usr/local/include/gtest/internal/gtest-internal.h:815:64: error: wrong number of template arguments (2, should be 3)
class TypeParameterizedTestSuite<Fixture, internal::None, Types> {
^
/usr/local/include/gtest/internal/gtest-internal.h:778:7: note: provided for ‘template<template<class T> class Fixture, class Tests, class Types> class testing::internal::TypeParameterizedTestSuite’
class TypeParameterizedTestSuite {
Edit:
I have edited the question with the error logs, and MAKE output while compiling the file. Thanks in advance for spending your time.
This is how I personally include Google Test in a clean way:
# To prevent overriding the parent project's compiler/linker settings on Windows.
if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
SOURCE_DIR "${GOOGLETEST_DOWNLOAD_DIR}/src" # choose preferred directory
BINARY_DIR "${GOOGLETEST_DOWNLOAD_DIR}/bin"
)
FetchContent_MakeAvailable(googletest)
#gtest and gtest-main will be available here
You can also use the FindGTest.cmake module with the find_package function make sure to define the environment variable GTEST_ROOT. If these methods would work while your method does not, then it could be your linker settings through cmake(check for syntax errors).

wchar.h: error: '__FILE' was not declared in this scope' error with gcc 5.2.0

I am having trouble compiling code
before it ever gets to the linker. Can anyone point me in the right
direction?
Here is the very simple code of source to reproduce this issue.
// CpxCryptoIfSimClientC.cpp //
#include <iostream>
// end
Compilation command line:
powerpc64-wrs-linux-g++ -c -o CpxCryptoIfSimClientC.o -m64 --sysroot=/proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux -ggdb -O3 -Wextra -Wall -DPOWERPC64 -DLNX -D_GNU_SOURCE -Os -fno-unit-at-a-time -pedantic -Wall -Wno-long-long `xml2-config --cflags` -std=gnu++98 -DINLINE=__inline__ -I../inc CpxCryptoIfSimClientC.cpp
Output:
In file included from /proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/c++/5.2.0/cwchar:44:0,
from /proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/c++/5.2.0/bits/postypes.h:40,
from /proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/c++/5.2.0/iosfwd:40,
from /proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/c++/5.2.0/ios:38,
from /proj/platform_cs/linux/deliveriessdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/c++/5.2.0/ostream:38,
from /proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/c++/5.2.0/iostream:39,
from ../../TestHelperStrategy_ppc64_linux/SimTestHelper.h:29,
from ../CpxCryptoIfSimClientC.h:25,
from ../CpxCryptoIfSimClientC.cpp:20:
/proj/platform_cs/linux/deliveries/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/wchar.h:582:8: error: '__FILE' does not name a type
extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
/proj/platform_cs/linux/deliveries/epb/epb_epb2_v1.52/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/wchar.h:589:19: error: '__FILE' was not declared in this scope extern int fwide (__FILE *__fp, int __mode) __THROW;
/proj/platform_cs/linux/deliveries/epb/epb_epb2_v1.52/sdk_install/sysroots/ppc64e6500-wrs-linux/usr/include/wchar.h:589:27: error: '__fp' was not declared in this scope extern int fwide (__FILE *__fp, int __mode) __THROW;
and many similiar errors which are "undeclared in this scope".
Here I am using gcc version 5.2.0 for powerpc64. Is there anything wrong with wchar.h or any other header file with this gcc version? or am I missing any flag here?

C++: what is wrong with abs

After a long time trace of my program I finally found that abs is the blameable part of my program. What should I expect from this code? why do I get:
x=0.1
|x|=0
#include <iostream>
int main()
{
double x=0.1;
std::cout<<"x="<<x<<std::endl;
std::cout<<"|x|="<<abs(x)<<std::endl;
return 0;
}
You may be wondering "But why I didnt get warning on g++ -g -Wall -Wfatal-errors -Wextra -std=c++11 test.cpp -o ./bin/test -lboost_filesystem -lboost_system?"
Turns out Wall isn't quite "all".
g++ -g -Wconversion -std=c++11 test.cpp -o tester -lboost_filesystem -lboost_system
test.cpp: In function ‘int main()’:
test.cpp:7:29: warning: conversion to ‘int’ from ‘double’ may alter its value [-Wconversion]
std::cout<<"|x|="<<abs(x)<<std::endl;
^
clang-3.6's diagnostic is clearer still, and no explicit opt-in required:
$ clang++ -std=c++11 test.cpp -o tester
test.cpp:8:24: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
std::cout<<"|x|="<<abs(x)<<std::endl;
^
test.cpp:8:24: note: use function 'std::abs' instead
std::cout<<"|x|="<<abs(x)<<std::endl;
^~~
std::abs
test.cpp:8:24: note: include the header <cmath> or explicitly provide a declaration for 'std::abs'
1 warning generated.
You're using the abs defined in <cstdlib>, which only works on integers.
Use the abs defined in <cmath> instead. It works on floating point values.

Qt + iperf3 = lconv has not been declared

Sorry for my english.
I try to add iperf3 (like static link library) to my Qt project (Qt version 4.8.5, OpenSuse 13.1), and has several errors:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../lperftest -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I../lperf/include -I. -I../lperftest -I. -o main.o ../lperftest/main.cpp
In file included from /usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:41:0,
from /usr/include/c++/4.8/bits/localefwd.h:40,
from /usr/include/c++/4.8/string:43,
from /usr/include/QtCore/qstring.h:54,
from /usr/include/QtCore/qobject.h:48,
from /usr/include/QtCore/QObject:1,
from ../lperftest/main.cpp:9:
/usr/include/c++/4.8/clocale:53:11: error: '::lconv' has not been declared
using ::lconv;
^
/usr/include/c++/4.8/clocale:54:11: error: '::setlocale' has not been declared
using ::setlocale;
^
/usr/include/c++/4.8/clocale:55:11: error: '::localeconv' has not been declared
using ::localeconv;
^
In file included from /usr/include/c++/4.8/bits/localefwd.h:40:0,
from /usr/include/c++/4.8/string:43,
from /usr/include/QtCore/qstring.h:54,
from /usr/include/QtCore/qobject.h:48,
from /usr/include/QtCore/QObject:1,
from ../lperftest/main.cpp:9:
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:52:23: error: 'uselocale' was not declared in this scope
extern "C" __typeof(uselocale) __uselocale;
^
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:52:45: error: invalid type in declaration before ';' token
extern "C" __typeof(uselocale) __uselocale;
^
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h: In function 'int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)':
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:75:53: error: '__gnu_cxx::__uselocale' cannot be used as a function
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
^
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:100:33: error: '__gnu_cxx::__uselocale' cannot be used as a function
__gnu_cxx::__uselocale(__old);
^
../lperftest/main.cpp: At global scope:
../lperftest/main.cpp:11:5: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char *argv[])
^
../lperftest/main.cpp:11:5: warning: unused parameter 'argv' [-Wunused-parameter]
make: *** [main.o] Error 1
When i try to add iperf3 to the only C++ project all is good. This error exist only in Qt project. Is any idea?
I have the same problem with iperf3 and Qt. Basically it seems that you have to use similar compilation for iperf3 library and your project (both gcc or both g++).
Let us know how it goes. Or share your solution if already done.
-- edit --
or do the following for iperf_api.h
extern "C" {
#include <iperf_api.h>
}

Mongo C++ Driver: mongo/client/dbclient.h: No such file or directory

I am trying to install the MongoDB C++ driver on my machine. I have followed the directions here, and everything seemed to install successfully. Still, I can't seem to include the headers. Here is a simple test program:
#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h"
void run() {
mongo::DBClientConnection c;
c.connect("localhost");
}
int main() {
try {
run();
std::cout << "connected ok" << std::endl;
} catch(const mongo::DBException &e) {
std::cout << "caught" << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
Here are the errors I get:
g++ app/tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -lboost_system -o tutorial
app/tutorial.cpp:3:35: error: mongo/client/dbclient.h: No such file or directory
app/tutorial.cpp: In function ‘void run()’:
app/tutorial.cpp:6: error: ‘mongo’ has not been declared
app/tutorial.cpp:6: error: expected `;' before ‘c’
app/tutorial.cpp:7: error: ‘c’ was not declared in this scope
app/tutorial.cpp: In function ‘int main()’:
app/tutorial.cpp:14: error: ISO C++ forbids declaration of ‘mongo’ with no type
app/tutorial.cpp:14: error: expected `)' before ‘::’ token
app/tutorial.cpp:14: error: expected `{' before ‘::’ token
app/tutorial.cpp:14: error: ‘::DBException’ has not been declared
app/tutorial.cpp:14: error: ‘e’ was not declared in this scope
app/tutorial.cpp:14: error: expected `;' before ‘)’ token
Any help would be greatly appreciated.
The line app/tutorial.cpp:3:35: error: mongo/client/dbclient.h: No such file or directory indicates that g++ is having difficulty finding the installed headers. In the tutorial that you linked to, the box below the suggested compilation command states
You may need to use -I and -L to specify the locations of your mongo and boost headers and libraries.
I'll assume that the installation procedure placed your header files in /usr/local/include and libraries (e.g. libmongoclient.a) in /usr/local/lib. Then, try adapting the compilation command to read
g++ -I/usr/local/include -L/usr/local/lib -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -lboost_system app/tutorial.cpp -o tutorial