Virtual machine problems mount windows directory compiler

Remember the process of resolving a problem, just look at from the knowledge of linux.

The problem is this, there is a code on the company's server compiler is no problem, then feel often pass code is compiled into the server a little trouble, I wanted to set up a build environment on its own virtual machine. After setting up the environment, accessed via mounted directly on a virtual machine under the code into native windows compiled, but compiled.

The problem can be streamlined in such a way, there is a cpp named Termios.cpp, its code contains Termios.h this header file, which contains the Termios.h termios.h. Termios.cpp and Termios.h their own code, termios.h is the head of the file system, do not ask me why I use the same name, the previous legacy code ~~~. In Termios.cpp which use macros such as B9600 and the like, in a virtual machine compile time error can not find the definition of the macro, but on the company's servers compile properly. Search termios.h follows :( company servers and virtual machines similar results)

Analyzing program references are /usr/include/termios.h, open the file found in the file contains the bits / termios.h, i.e. /usr/include/x86_64-linux-gnu/bits/termios.h, in this document there macro definitions and the like, such as B9600. Virtual machine contents inside documents, too, why the compiler error it? The first point suspect inside the virtual machine that contains not /usr/include/termios.h, "qztest" This program determines the print content does not contain this header file by adding # error in the header file. Is termios.h included in other directories? Search by gcc look unlikely path (search path see my article https://blog.csdn.net/wuzhidefeng/article/details/76854655 ), but do not worry, in other directories also add a # error "qztest" did not find such a macro that contains these headers. But when gcc compiler is not able to find the header file that references a program in the end is where the first document it?

Useful command came, g ++ -M command. By g ++ -M Termios.cpp -I ../inc/ -I ../../globalinclude/ -std = c ++ 11 | grep termi separately compiled about this cpp to see him in the end use to which the header files, the results as follows:

The results show he found ../inc/termios.h, but only into this directory Termios.h, this document does not termios.h ah. Ll find in the directory and the files are not found, is it gcc not case-sensitive? Unreasonable ah. Try Termios.h copy into a Termios1.h, and then included in the Termios.cpp in Termios1.h, re-use g ++ -M still found ../inc/termios.h. The termios.h renamed, recompile, before adding the # error "qztest" printed out. Termios.h termios.h seems to be as self-contained.

Then do not mount by the way, simply copy the entire virtual machine inside the code to recompile, there is no error, compile successfully.

Conclusion: under the code access windows in ubuntu mount, gcc compile time can be misleading, case-insensitive (to be specific deep-seated reasons behind the free and then get to the bottom)

Lesson: 1, file naming to regulate, not to engage in such as file name, only in case the same thing, not system files and duplicate names

           2, try not to cross-platform access files directly, you can copy it and then access

Published 12 original articles · won praise 4 · views 20000 +

Guess you like

Origin blog.csdn.net/wuzhidefeng/article/details/105298654