Tag Archives: c++

[Solved] unesolved external symbol _imp_fprintf referenced in funciton _showerror

There are two problems when debugging projects written in ffmpeg with vs2015:

Question 1:

“LNK2019 unresolved external symbol __imp____iob_func reference in function _ShowError”

Solution: add this sentence to the source code: extern “C” {file _iob_func [3] = {* stdin, * stdout, * stderr};}

Question 2:

“unesolved external symbol _imp_fprintf referenced in funciton _showerror”

Solution: right-click the item — properties — configuration — linker — input — additional dependencies to add the library legacy_stdio_definitions.lib

error C4996: ‘pcl::SAC_SAMPLE_SIZE‘ [How to Solve]

Error: pcl-1.8\pcl\sample_consensus\model_types.h(99): error C4996: ‘pcl::SAC_SAMPLE_SIZE’: This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class

Solution:
Open the project property page > C/C++ > General > SDL Check (set to No).

[Solved] MAC Compile Error: fatal error: ‘endian.h‘ file not found

Specific error

In file included from conf.c:427:
In file included from ../include/local.h:146:
In file included from ../include/sound/asound.h:4:
../include/alsa/sound/uapi/asound.h:31:10: fatal error: 'endian.h' file not
      found
#include <endian.h>

Solution:

Change to <machine/endian.h> Just.

Others say it should be changed to <Endian.h>, Tried, it didn’t work!

VSCode Unable to find custom header file directory: fatal error: no such file or directory

The solution is as follows:

First, add the path of the folder where your header file is located in "includepath":[] of C_cpp_properties.json.

Of course, this step is only to tell the vscode header file where it is for debugging, but it is not known when GCC compiles. We know that if you use G + + main.CPP - I library_path - O main can be compiled successfully directly, so we just need to tell vscode to use our own defined commands

There are generally two methods. The first is to add “- I header_file_path” to the args key in tasks.json, as follows:

	"args": [
		"-g",
		"${workspaceFolder}\\src\\*.cpp",
		"-o",
		"${fileDirname}\\src\\${fileBasenameNoExtension}.exe",
		"-I",
		"header_file_path"
	],

But it doesn’t seem to work well in some cases.

The second method is to directly set in setting.json:

  "code-runner.executorMap": {
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -I 'header_file_path' && $dir$fileNameWithoutExt",
  }

[Solved] ORB_SLAM3 Compile Error: opencv4.0 not found four

CMake Warning at CMakeLists.txt:33 (find_package):
  Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "4.4".

  The following configuration files were considered but not accepted:

    /usr/share/OpenCV/OpenCVConfig.cmake, version: 3.2.0



CMake Error at CMakeLists.txt:35 (message):
  OpenCV > 4.4 not found.


-- Configuring incomplete, errors occurred!
See also "/home/tys/ORB_SLAM3/build/CMakeFiles/CMakeOutput.log".
make: *** No target specified and no makefile found. Stop.

The content of the error report is as above. I found a solution, and there is a solution available.

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 4.4)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 4.4 not found.")
   endif()

Find the above location in CMakeList.txt in the ORB_SLAM3 folder and modify

find_package(OpenCV 4.4), as shown in the following code.

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 3 REQUIRED)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 4.4 not found.")
   endif()

Normal, so that the fault can be solved.

[Solved] QT error: error: undefined reference to ` VTable`

Question:

QT compilation error:

error: undefined reference to `vtable ...`

 

reason:

1.Qt uses signals and slots to implement communication features.
2.Signals and slots can be used when the class is derived from QObject and the Q_OBJECT macro is added to the header file.
3.When Q_OBJECT is added to the class header file QtCreator will automatically create a moc_***.cpp file that implements the code for signal and slot communication.
4.However, sometimes when we create a class through QtCreator without selecting the IDE option to derive it from the QObject class, but add it later, QtCreator will not automatically create the moc_***.cpp file. In this case it will report an error: undefined reference to `vtable for ***.

 

Solution:

According to various online methods, it can not be solved, nor can rebuild
mine is a small project. Just delete the build-XXX folder and rebuild it.

error: stray ‘\343’ in program [How to Solve]

Problem phenomenon:

Cause of problem:

This error is basically generated by copying the code from the web page and compiling it. Because the copied code contains Chinese spaces and characters, it can’t be distinguished by the naked eye.

Solution:

1. When the amount of code is small, it is best to re type it at the error location, then save it and recompile it.

Error prompts the location information of the error. Find the corresponding place to change.

2. It can also be used when there are many codes, or the replacement function of GEDIT can be used to replace with standard spaces, which is more labor-saving.

Find characters in error:

Under Linux, you can:

cat xxx.c -A

Chinese will be displayed as characters with red lines.

[Solved] CMake Error: The current CMakeCache.txt directory is different than xxx

CMake Error: The current CMakeCache.txt directory xxx/CMakeCache.txt
is different than the directory
xxx where CMakeCache.txt was created. This may result in binaries being
created in the wrong place. If you are not sure, reedit the
CMakeCache.txt CMake Error: The source
“xxx/CMakeLists.txt”
does not match the source
“xxx/CMakeLists.txt”
used to generate cache. Re-run cmake with a different source
directory.


You copied the project file, but the cache file in the build still retains the previous information. Just delete the build folder and recompile.

error: ‘integer_sequence’ is not a member of ‘std’ [How to Solve]

I encountered this error when compiling the camodacal project:

/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
 struct SumImpl<std::integer_sequence<T, N, Ns...>> {
                     ^~~~~~~~~~~~~~~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:46: error: wrong number of template arguments (3, should be 1)
 struct SumImpl<std::integer_sequence<T, N, Ns...>> {
                                              ^~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:60:8: note: provided for ‘template<class Seq> struct ceres::internal::SumImpl’
 struct SumImpl;
        ^~~~~~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:49: error: expected unqualified-id before ‘>’ token
 struct SumImpl<std::integer_sequence<T, N, Ns...>> {
                                                 ^~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:71:21: error: ‘integer_sequence’ is not a member of ‘std’
 struct SumImpl<std::integer_sequence<T, N1, N2, Ns...>> {
                     ^~~~~~~~~~~~~~~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:71:21: error: ‘integer_sequence’ is not a member of ‘std’
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:71:51: error: wrong number of template arguments (4, should be 1)
 struct SumImpl<std::integer_sequence<T, N1, N2, Ns...>> {
                                                   ^~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:60:8: note: provided for ‘template<class Seq> struct ceres::internal::SumImpl’
 struct SumImpl;
        ^~~~~~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:71:54: error: expected unqualified-id before ‘>’ token
 struct SumImpl<std::integer_sequence<T, N1, N2, Ns...>> {
                                                      ^~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:78:21: error: ‘integer_sequence’ is not a member of ‘std’
 struct SumImpl<std::integer_sequence<T, N1, N2, N3, N4, Ns...>> {
                     ^~~~~~~~~~~~~~~~
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:78:21: error: ‘integer_sequence’ is not a member of ‘std’

In the final analysis, it is the version of Ceres. There are many online solutions that may work for other projects:

Modify the cmakelists file:

set(CMAKE_CXX_FLAGS "-std=c++11")

Is:

set(CMAKE_CXX_STANDARD 11)

Or:

set(CMAKE_CXX_STANDARD 14)

Details can be found in the ceres source code description at:
https://github.com/ceres-solver/ceres-solver/issues/604
But if it still doesn’t work, for example if I compile an old project like CamOdoCal, I can return the ceres version to 1.1.4

[Solved] Fatal error C1001 internal error occurred in the compiler openmesh6 three

Internal Compiler Error VS 2015 Update1
VS2015 Update1 An error occurred when compiling the OpenMesh code:

fatal error c1001 An internal error occurred in the compiler OpenMesh6.3
(compiler file ‘f:\dd\vctools\compiler\cxxfe\sl\p1\c\special.c’, line 6211)
1> To work around this problem, try simplifying or changing the program near the locations listed above.

The reason is that codes such as this appear

OpenMesh::Vec3f normal[4];

Solution: change this kind of code to the following.

OpenMesh::Vec3f normal[4] = { {},{},{},{} };