精华内容
参与话题
问答
  • GCC(GNU Compiler Collection,GNU编译器套件)

    千次阅读 多人点赞 2019-05-04 23:19:00
    GCC(GNU Compiler Collection,GNU编译器套件),是由GNU开发的编程语言编译器。 gcc主要软件包如下: 名称 功能描述 cpp C 预处理器 gcc C 编译器 g++ C++编译器 gccbug 创建BUG报告的Shell脚本 ...



    GCCGNU Compiler CollectionGNU编译器套件),是由GNU开发的编程语言编译器

    1、 GCC 主要软件包

    序号 名称 功能描述
    1 cpp C预处理器
    2 gcc C编译器
    3 g++ C++编译器
    4 gccbug 创建BUG报告的Shell脚本
    5 gcov 覆盖测试工具,用于分析在程序的哪个位置做优化效果最佳
    6 libgcc GCC运行库
    7 libstdc++ 标准C++库
    8 libsupc++ 提供支持C++语言的函数库

    2、 GCC 编译过程

    2.1 GCC 编译过程

    hello.chello(或a.out)文件,必须历经hello.ihello.shello.o,最后才得到 hello(或a.out)文件,分别对应着预处理编译汇编链接4个步骤,整个过程如图所示:
    在这里插入图片描述

    序号 步骤 工作内容
    1 预处理(Preprocess) C 编译器对各种预处理命令进行处理,包括:
    (1)展开所有的头文件
    (2)宏定义的替换
    (3)解析条件编译添加到文件中
    2 编译(Compile) 预处理后的文件进行词法分析语法分析语义分析优化后,生成相应的.s汇编文件
    3 汇编(Assemble) 编译后的汇编代码翻译成机器码,生成.o目标文件
    4 链接(Link) 通过链接器ld目标文件库文件链接在一起,生成可执行文件(executable file)

    序号 命令 描述
    1 gcc -E hello.c -o hello.i 预处理(预处理器 Preprocessor:cpp-E:只对文件进行预处理,不编译汇编和链接)
    2 gcc -S hello.i -o hello.s 编译(编译器 Compiler:gccg++-S:只对文件进行编译,不汇编和链接)
    3 gcc hello.s -o hello.o 汇编(汇编器 Assembler:as)
    4 gcc hello.o -o hello 链接(链接器 Linker:ld)

    2.2 GCC 单步完成编译

    第1种命令:gcc hello.c -o hello
    第2种命令:gcc -o hello hello.c

    3、GCC 常用 选项和参数

    序号 命令 描述
    1 -c 只编译不链接为可执行文件,编译器将输入的.c文件编译为.o目标文件
    2 -o output_file output_file 用来指定编译结束以后的输出文件名
    如果不使用这个选项的话 GCC 默认编译出来的可执行文件名字为a.out
    3 -E 只对文件进行预处理,不编译汇编和链接
    4 -S 只对文件进行编译,不汇编和链接
    5 -g 产生符号调试工具(GNU 的 GDB)所必要的符号信息,要想对源代码进行调试,就必须加入这个选项。
    g也分等级,默认是-g2-g1是最基本的,-g3包含宏信息
    6 -O 对程序进行优化编译,如果使用此选项的话整个源代码在编译链接的的时候都会进行优化,这样产生的可执行文件执行效率就高
    7 -ON 指定代码的优化等级为N,可取值为 0,1,2,3
    O0没有优化,O3优化级别最高
    8 -O2 -O更幅度更大的优化,生成的可执行效率更高,但是整个编译过程会很慢

    4、C/C++ 程序 常用文件名后缀

    序号 扩展名 说明
    1 .a 静态库,由目标文件构成的文件库
    2 .c C源码,必须经过预处理
    3 .C .cc .cpp C++源码,必须经过预处理
    4 .h C/C++源码的头文件
    5 .i .c经过预处理得到的C源码
    6 .ii .C .cc .cpp经过预处理得到的C++源码
    7 .s 汇编语言文件,是.i文件编译后得到的中间文件
    8 .o 目标文件,是编译过程得到的中间文件
    9 .so 共享对象库(shared object),也称动态库

    5、 链接 可分为 动态链接 和 静态链接

    序号 链接 描述
    1 动态链接 使用动态库进行链接,生成的程序在执行的时候需要加载所需的动态库才能运行。
    动态链接生成的程序小巧,但是必须依赖动态库,否则无法执行
    2 静态链接 使用静态库进行链接,生成的程序包含程序运行所需要的全部库,可以直接运行,不过体积较大

    Linux 下的动态链接库实际是共享目标文件(shared object),一般是.so文件,作用类似于 Windows 下的.dll文件。

    展开全文
  • mvn clean package -Dmaven.test.skip=true 今天项目用maven命令...Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project springbootdemo: Fata...
    mvn clean package -Dmaven.test.skip=true

    今天项目用maven命令打包时候抛出错误:

    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project springbootdemo: Fatal error compiling: 无效的标记: -parameters -> [Help 1]

    这个错误的话比较好解决,是由于你项目所需jdk版本和你当前使用的jdk版本不一致导致的,因为我项目的pom.xml中定义了java版本为1.8,但是我实际idea中run这个项目却是1.7

        <java.version>1.8</java.version>

    解决办法:更换当前jdk版本为项目所需jdk版本即可

    要是你在intellij idea里面的maven窗口点击的打包编译的话,就在intellij idea设置项目jdk版本,直接Ctrl+Alt+s进入设置界面

    选中项目右击 》F4键设置项目属性进入

    如果你是直接在windows里的cmd中用maven打包的,那就需要切换你的jdk环境。如上设置好后再重新打包编译ok!

    其他情况也可能会导致这个错误:

    1、当你用类似于 java -jar ~.jar 命令在运行项目时候,此时你再打包项目,也会导致打包失败报错;

    2、你的pom.xml文件里配置的依赖不对(可能是版本、名称之类的),jar包没下来,请仔细核对pom.xml是否报错,像idea里如果依赖不对,在maven project窗口是可以直接看得到的。


    books 扩展阅读:使用quartz实现高级定制化定时任务(包含管理界面)

    books 推荐阅读:elastic search搜索引擎实战demo:https://github.com/simonsfan/springboot-quartz-demo,分支:feature_es

    展开全文
  • Compiler

    千次阅读 2013-09-09 16:07:19
    http://en.wikipedia.org/wiki/Compiler ...Compiler From Wikipedia, the free encyclopedia This article is about the computing term. For the anime, see Compiler (anime). A

    http://en.wikipedia.org/wiki/Compiler

    Compiler

    From Wikipedia, the free encyclopedia
    A diagram of the operation of a typical multi-language, multi-target compiler

    compiler is a computer program (or set of programs) that transformssource code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.

    The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code). If the compiled program can run on a computer whose CPU or operating system is different from the one on which the compiler runs, the compiler is known as a cross-compiler. A program that translates from a low level language to a higher level one is adecompiler. A program that translates between high-level languages is usually called a language translatorsource to source translator, orlanguage converter. A language rewriter is usually a program that translates the form of expressions without a change of language.

    A compiler is likely to perform many or all of the following operations: lexical analysispreprocessingparsing, semantic analysis (Syntax-directed translation), code generation, and code optimization.

    Program faults caused by incorrect compiler behavior can be very difficult to track down and work around; therefore, compiler implementors invest significant effort to ensure compiler correctness.

    The term compiler-compiler is sometimes used to refer to a parser generator, a tool often used to help create the lexer and parser.

    History[edit source | editbeta]

    Software for early computers was primarily written in assembly language. Higher level programming languages were not invented until the benefits of being able to reuse software on different kinds of CPUs started to become significantly greater than the costs of writing a compiler. The limited memory capacity of early computers led to substantial technical challenges when the first compilers were being designed.

    Towards the end of the 1950s, machine-independent programming languages were first proposed. Subsequently several experimental compilers were developed. The first compiler was written by Grace Hopper, in 1952, for the A-0 programming language. The FORTRAN team led by John Backus at IBM is generally credited as having introduced the first complete compiler in 1957. COBOL was an early language to be compiled on multiple architectures, in 1960.[1]

    In many application domains the idea of using a higher level language quickly caught on. Because of the expanding functionality supported by newer programming languages and the increasing complexity of computer architectures, compilers have become more complex.

    Early compilers were written in assembly language. The first self-hosting compiler — capable of compiling its own source code in a high-level language — was created in 1962 for Lisp by Tim Hart and Mike Levin at MIT.[2] Since the 1970s it has become common practice to implement a compiler in the language it compiles, although both Pascal and C have been popular choices for implementation language. Building a self-hosting compiler is a bootstrapping problem—the first such compiler for a language must be compiled either by hand or by a compiler written in a different language, or (as in Hart and Levin's Lisp compiler) compiled by running the compiler in an interpreter.

    Compilers in education[edit source | editbeta]

    Compiler construction and compiler optimization are taught at universities and schools as part of a computer sciencecurriculum.[3] Such courses are usually supplemented with the implementation of a compiler for an educational programming language. A well-documented example is Niklaus Wirth's PL/0 compiler, which Wirth used to teach compiler construction in the 1970s.[4] In spite of its simplicity, the PL/0 compiler introduced several influential concepts to the field:

    1. Program development by stepwise refinement (also the title of a 1971 paper by Wirth)[5]
    2. The use of a recursive descent parser
    3. The use of EBNF to specify the syntax of a language
    4. code generator producing portable P-code
    5. The use of T-diagrams[6] in the formal description of the bootstrapping problem

    Compilation[edit source | editbeta]

    Compilers enabled the development of programs that are machine-independent. Before the development of FORTRAN (FORmula TRANslator), the first higher-level language, in the 1950s, machine-dependent assembly language was widely used. Whileassembly language produces more abstraction than machine code on the same architecture, just as with machine code, it has to be modified or rewritten if the program is to be executed on different computer hardware architecture.

    With the advance of high-level programming languages that followed FORTRAN, such as COBOLC, and BASIC, programmers could write machine-independent source programs. A compiler translates the high-level source programs into target programs in machine languages for the specific hardwares. Once the target program is generated, the user can execute the program.

    Structure of a compiler[edit source | editbeta]

    Compilers bridge source programs in high-level languages with the underlying hardware. A compiler requires 1) determining the correctness of the syntax of programs, 2) generating correct and efficient object code, 3) run-time organization, and 4) formatting output according to assembler and/or linker conventions. A compiler consists of three main parts: the frontend, the middle-end, and the backend.

    The front end checks whether the program is correctly written in terms of the programming language syntax and semantics. Here legal and illegal programs are recognized. Errors are reported, if any, in a useful way. Type checking is also performed by collecting type information. The frontend then generates an intermediate representation or IR of the source code for processing by the middle-end.

    The middle end is where optimization takes place. Typical transformations for optimization are removal of useless or unreachable code, discovery and propagation of constant values, relocation of computation to a less frequently executed place (e.g., out of a loop), or specialization of computation based on the context. The middle-end generates another IR for the following backend. Most optimization efforts are focused on this part.

    The back end is responsible for translating the IR from the middle-end into assembly code. The target instruction(s) are chosen for each IR instruction. Register allocation assigns processor registers for the program variables where possible. The backend utilizes the hardware by figuring out how to keep parallel execution units busy, filling delay slots, and so on. Although most algorithms for optimization are in NP, heuristic techniques are well-developed.

    Compiler output[edit source | editbeta]

    One classification of compilers is by the platform on which their generated code executes. This is known as the target platform.

    native or hosted compiler is one which output is intended to directly run on the same type of computer and operating system that the compiler itself runs on. The output of a cross compiler is designed to run on a different platform. Cross compilers are often used when developing software for embedded systems that are not intended to support a software development environment.

    The output of a compiler that produces code for a virtual machine (VM) may or may not be executed on the same platform as the compiler that produced it. For this reason such compilers are not usually classified as native or cross compilers.

    The lower level language that is the target of a compiler may itself be a high-level programming languageC, often viewed as some sort of portable assembler, can also be the target language of a compiler. E.g.: Cfront, the original compiler for C++ used C as target language. The C created by such a compiler is usually not intended to be read and maintained by humans. So indent style and pretty C intermediate code are irrelevant. Some features of C turn it into a good target language. E.g.: C code with#line directives can be generated to support debugging of the original source.

    Compiled versus interpreted languages[edit source | editbeta]

    Higher-level programming languages usually appear with a type of translation in mind: either designed as compiled language orinterpreted language. However, in practice there is rarely anything about a language that requires it to be exclusively compiled or exclusively interpreted, although it is possible to design languages that rely on re-interpretation at run time. The categorization usually reflects the most popular or widespread implementations of a language — for instance, BASIC is sometimes called an interpreted language, and C a compiled one, despite the existence of BASIC compilers and C interpreters.

    Interpretation does not replace compilation completely. It only hides it from the user and makes it gradual. Even though an interpreter can itself be interpreted, a directly executed program is needed somewhere at the bottom of the stack (see machine language). Modern trends toward just-in-time compilation and bytecode interpretation at times blur the traditional categorizations of compilers and interpreters.

    Some language specifications spell out that implementations must include a compilation facility; for example, Common Lisp. However, there is nothing inherent in the definition of Common Lisp that stops it from being interpreted. Other languages have features that are very easy to implement in an interpreter, but make writing a compiler much harder; for example, APLSNOBOL4, and many scripting languages allow programs to construct arbitrary source code at runtime with regular string operations, and then execute that code by passing it to a special evaluation function. To implement these features in a compiled language, programs must usually be shipped with a runtime library that includes a version of the compiler itself.

    Hardware compilation[edit source | editbeta]

    The output of some compilers may target computer hardware at a very low level, for example a Field Programmable Gate Array(FPGA) or structured Application-specific integrated circuit (ASIC). Such compilers are said to be hardware compilers or synthesis tools because the source code they compile effectively controls the final configuration of the hardware and how it operates; the output of the compilation is not instructions that are executed in sequence - only an interconnection of transistors or lookup tables. For example, XST is the Xilinx Synthesis Tool used for configuring FPGAs. Similar tools are available from Altera, Synplicity, Synopsys and other vendors.

    Compiler construction[edit source | editbeta]

    In the early days, the approach taken to compiler design used to be directly affected by the complexity of the processing, the experience of the person(s) designing it, and the resources available.

    A compiler for a relatively simple language written by one person might be a single, monolithic piece of software. When the source language is large and complex, and high quality output is required, the design may be split into a number of relatively independent phases. Having separate phases means development can be parceled up into small parts and given to different people. It also becomes much easier to replace a single phase by an improved one, or to insert new phases later (e.g., additional optimizations).

    The division of the compilation processes into phases was championed by the Production Quality Compiler-Compiler Project(PQCC) at Carnegie Mellon University. This project introduced the terms front endmiddle end, and back end.

    All but the smallest of compilers have more than two phases. However, these phases are usually regarded as being part of the front end or the back end. The point at which these two ends meet is open to debate. The front end is generally considered to be where syntactic and semantic processing takes place, along with translation to a lower level of representation (than source code).

    The middle end is usually designed to perform optimizations on a form other than the source code or machine code. This source code/machine code independence is intended to enable generic optimizations to be shared between versions of the compiler supporting different languages and target processors.

    The back end takes the output from the middle. It may perform more analysis, transformations and optimizations that are for a particular computer. Then, it generates code for a particular processor and OS.

    This front-end/middle/back-end approach makes it possible to combine front ends for different languages with back ends for different CPUs. Practical examples of this approach are the GNU Compiler CollectionLLVM, and the Amsterdam Compiler Kit, which have multiple front-ends, shared analysis and multiple back-ends.

    One-pass versus multi-pass compilers[edit source | editbeta]

    Classifying compilers by number of passes has its background in the hardware resource limitations of computers. Compiling involves performing lots of work and early computers did not have enough memory to contain one program that did all of this work. So compilers were split up into smaller programs which each made a pass over the source (or some representation of it) performing some of the required analysis and translations.

    The ability to compile in a single pass has classically been seen as a benefit because it simplifies the job of writing a compiler and one-pass compilers generally perform compilations faster than multi-pass compilers. Thus, partly driven by the resource limitations of early systems, many early languages were specifically designed so that they could be compiled in a single pass (e.g., Pascal).

    In some cases the design of a language feature may require a compiler to perform more than one pass over the source. For instance, consider a declaration appearing on line 20 of the source which affects the translation of a statement appearing on line 10. In this case, the first pass needs to gather information about declarations appearing after statements that they affect, with the actual translation happening during a subsequent pass.

    The disadvantage of compiling in a single pass is that it is not possible to perform many of the sophisticated optimizations needed to generate high quality code. It can be difficult to count exactly how many passes an optimizing compiler makes. For instance, different phases of optimization may analyse one expression many times but only analyse another expression once.

    Splitting a compiler up into small programs is a technique used by researchers interested in producing provably correct compilers. Proving the correctness of a set of small programs often requires less effort than proving the correctness of a larger, single, equivalent program.

    While the typical multi-pass compiler outputs machine code from its final pass, there are several other types:

    • A "source-to-source compiler" is a type of compiler that takes a high level language as its input and outputs a high level language. For example, an automatic parallelizing compiler will frequently take in a high level language program as an input and then transform the code and annotate it with parallel code annotations (e.g. OpenMP) or language constructs (e.g. Fortran's DOALL statements).
    • Stage compiler that compiles to assembly language of a theoretical machine, like some Prolog implementations
    • Just-in-time compiler, used by Smalltalk and Java systems, and also by Microsoft .NET's Common Intermediate Language (CIL)
      • Applications are delivered in bytecode, which is compiled to native machine code just prior to execution.

    Front end[edit source | editbeta]

    The compiler frontend analyzes the source code to build an internal representation of the program, called the intermediate representation or IR. It also manages the symbol table, a data structure mapping each symbol in the source code to associated information such as location, type and scope. This is done over several phases, which includes some of the following:

    1. Line reconstruction. Languages which strop their keywords or allow arbitrary spaces within identifiers require a phase before parsing, which converts the input character sequence to a canonical form ready for the parser. The top-downrecursive-descent, table-driven parsers used in the 1960s typically read the source one character at a time and did not require a separate tokenizing phase. Atlas Autocode, and Imp (and some implementations of ALGOL and Coral 66) are examples of stropped languages which compilers would have a Line Reconstruction phase.
    2. Lexical analysis breaks the source code text into small pieces called tokens. Each token is a single atomic unit of the language, for instance a keywordidentifier or symbol name. The token syntax is typically a regular language, so a finite state automaton constructed from a regular expression can be used to recognize it. This phase is also called lexing or scanning, and the software doing lexical analysis is called a lexical analyzer or scanner. This may not be a separate step – it can be combined with the parsing step in scannerless parsing, in which case parsing is done at the character level, not the token level.
    3. Preprocessing. Some languages, e.g., C, require a preprocessing phase which supports macro substitution and conditional compilation. Typically the preprocessing phase occurs before syntactic or semantic analysis; e.g. in the case of C, the preprocessor manipulates lexical tokens rather than syntactic forms. However, some languages such as Scheme support macro substitutions based on syntactic forms.
    4. Syntax analysis involves parsing the token sequence to identify the syntactic structure of the program. This phase typically builds a parse tree, which replaces the linear sequence of tokens with a tree structure built according to the rules of a formal grammar which define the language's syntax. The parse tree is often analyzed, augmented, and transformed by later phases in the compiler.
    5. Semantic analysis is the phase in which the compiler adds semantic information to the parse tree and builds the symbol table. This phase performs semantic checks such as type checking (checking for type errors), or object binding (associating variable and function references with their definitions), or definite assignment (requiring all local variables to be initialized before use), rejecting incorrect programs or issuing warnings. Semantic analysis usually requires a complete parse tree, meaning that this phase logically follows the parsing phase, and logically precedes the code generation phase, though it is often possible to fold multiple phases into one pass over the code in a compiler implementation.

    Back end[edit source | editbeta]

    The term back end is sometimes confused with code generator because of the overlapped functionality of generating assembly code. Some literature uses middle end to distinguish the generic analysis and optimization phases in the back end from the machine-dependent code generators.

    The main phases of the back end include the following:

    1. Analysis: This is the gathering of program information from the intermediate representation derived from the input. Typical analyses are data flow analysis to build use-define chainsdependence analysisalias analysispointer analysisescape analysis etc. Accurate analysis is the basis for any compiler optimization. The call graph and control flow graph are usually also built during the analysis phase.
    2. Optimization: the intermediate language representation is transformed into functionally equivalent but faster (or smaller) forms. Popular optimizations are inline expansiondead code eliminationconstant propagationloop transformation,register allocation and even automatic parallelization.
    3. Code generation: the transformed intermediate language is translated into the output language, usually the nativemachine language of the system. This involves resource and storage decisions, such as deciding which variables to fit into registers and memory and the selection and scheduling of appropriate machine instructions along with their associated addressing modes (see also Sethi-Ullman algorithm). Debug data may also need to be generated to facilitate debugging.

    Compiler analysis is the prerequisite for any compiler optimization, and they tightly work together. For example, dependence analysis is crucial for loop transformation.

    In addition, the scope of compiler analysis and optimizations vary greatly, from as small as a basic block to the procedure/function level, or even over the whole program (interprocedural optimization). Obviously, a compiler can potentially do a better job using a broader view. But that broad view is not free: large scope analysis and optimizations are very costly in terms of compilation time and memory space; this is especially true for interprocedural analysis and optimizations.

    Interprocedural analysis and optimizations are common in modern commercial compilers from HPIBMSGIIntelMicrosoft, andSun Microsystems. The open source GCC was criticized for a long time for lacking powerful interprocedural optimizations, but it is changing in this respect. Another open source compiler with full analysis and optimization infrastructure is Open64, which is used by many organizations for research and commercial purposes.

    Due to the extra time and space needed for compiler analysis and optimizations, some compilers skip them by default. Users have to use compilation options to explicitly tell the compiler which optimizations should be enabled.

    Compiler correctness[edit source | editbeta]

    Compiler correctness is the branch of software engineering that deals with trying to show that a compiler behaves according to itslanguage specification.[citation needed] Techniques include developing the compiler using formal methods and using rigorous testing (often called compiler validation) on an existing compiler.

    Related techniques[edit source | editbeta]

    Assembly language is a type of low-level language and a program that compiles it is more commonly known as an assembler, with the inverse program known as a disassembler.

    A program that translates from a low level language to a higher level one is a decompiler.

    A program that translates between high-level languages is usually called a language translatorsource to source translator,language converter, or language rewriter. The last term is usually applied to translations that do not involve a change of language.

    A program that translates into an object code format that is not supported on the compilation machine is called a cross compilerand is commonly used to prepare code for embedded applications.

    International conferences and organizations[edit source | editbeta]

    Every year, the European Joint Conferences on Theory and Practice of Software (ETAPS) sponsors the International Conference on Compiler Construction, with papers from both the academic and industrial sectors.[7]

    See also[edit source | editbeta]

    Notes[edit source | editbeta]

    1. ^ "IP: The World's First COBOL Compilers". interesting-people.org. 12 June 1997.
    2. ^ T. Hart and M. Levin. "The New Compiler, AIM-39 - CSAIL Digital Archive - Artificial Intelligence Laboratory Series". publications.ai.mit.edu.
    3. ^ Chakraborty, P., Saxena, P. C., Katti, C. P., Pahwa, G., Taneja, S. A new practicum in compiler construction. Computer Applications in Engineering Education, In Press.http://onlinelibrary.wiley.com/doi/10.1002/cae.20566/pdf
    4. ^ "The PL/0 compiler/interpreter".
    5. ^ "The ACM Digital Library".
    6. ^ T diagrams were first introduced for describing bootstrapping and cross-compiling compilers in McKeeman et al. A Compiler Generator (1971). Conway described the broader concept before that with his UNCOL in 1958, to which Bratman added in 1961: H. Bratman, “An alternate form of the ´UNCOL diagram´“, Comm. ACM 4 (March 1961) 3, p. 142. Later on, others, including P.D. Terry, gave an explanation and usage of T-diagrams in their textbooks on the topic of compiler construction. Cf. Terry, 1997, Chapter 3. T-diagrams are also now used to describe client-server interconnectivity on the World Wide Web: cf. Patrick Closhen, et al. 1997: T-Diagrams as Visual Language to Illustrate WWW Technology, Darmstadt University of Technology, Darmstadt, Germany
    7. ^ ETAPS - European Joint Conferences on Theory and Practice of Software. Cf. "CC" (Compiler Construction) subsection.

    References[edit source | editbeta]

    External links[edit source | editbeta]


    展开全文
  • 背景:本项目使用JDK...Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1 pom中如下配置maven插件,配置中声明使用JDK1.8: org.apache.maven.plugins maven-compiler-plugin 3

    背景:本项目使用JDK1.8

    编译maven工程的时候出现如下错误:

    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1

    pom中如下配置maven插件,配置中声明使用JDK1.8:

    <plugin>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-compiler-plugin</artifactId>
    	<version>3.1</version>
    	<configuration>
    		<verbose>true</verbose>
    		<fork>true</fork>
    		<executable>${JAVA8_HOME}/bin/javac</executable>
    	</configuration>
    </plugin>

    这里的${JAVA8_HOME}这个变量是在settings.xml中配置的,如下:

    <profile>
                <id>custom-compiler</id>
                <properties>
                    <JAVA8_HOME>C:\Program Files (x86)\Java\jdk1.8.0_73</JAVA8_HOME>
                </properties>
    </profile>
    当然这里应该需要激活,所以settings.xml文件还应该有如下配置:

    <activeProfiles>
            <activeProfile>custom-compiler</activeProfile>
    </activeProfiles>
    从pom文件中CTRL点击变量JAVA8_HOME能跳到settings.xml中找到它的定义处,按理来说应该是能找到这个变量,出现上述问题并不是因为找不到这个变量。我将pom文件中的JAVA8_HOME这个变量直接用实际的路径替换,即替换为
    C:\Program Files (x86)\Java\jdk1.8.0_73\bin\javac
    发现编译通过,这就奇怪了。

    揭晓原因:

    maven其实是有一个默认的仓库.m2仓库和默认的settings.xml配置文件,我们在这个默认的settings.xml文件中也添加了一个JAVA8_HOME的变量后,编译就通过了,这就说明,maven编译的时候找的不是我在idea中配置的我自定义的settings.xml,而是先找的它默认的那个。因为里面没有,所以之前找不到JAVA8_HOME,导致编译失败、

    总结:maven编译的时候应该是先找的默认的settings.xml,如果找不到,才会去找我在idea的settings选项下配置的“User settings file”中配置的settings.xml文件。

    解决办法:删掉maven默认的去找的那个settings.xml文件,这样自定义的文件就会生效了



    展开全文
  • 1.code::blocks setting - compiler setting 菜单中没有global compiler setting 无法编译 2.找不到编译(构建按钮),无法编译 3.运行CbLauncher.exe 可以编译 ![图片说明]...
  • Python之compilercompiler库的简介、安装、使用方法之详细攻略 目录 compiler库的简介 compiler库的安装 compiler库的使用方法 compiler库的简介 根据文件名自动编译运行程序,基于文件类型...
  • Error:java: Compilation failed: internal java compiler error 错误原因 导致这个错误的原因主要是因为jdk版本问题,此处有两个原因,一个是编译版本不匹配,一个是当前项目jdk版本不支持。 查看项目的jdk...
  • Benny's Compiler

    2017-03-22 06:05:16
    These days Benny has designed a new compiler for C programming language. His compilation system provides a compiler driver that invokes the language preprocessor, compiler, assembler and linker. C ...
  • The C compiler identification is MSVC 19.0.24215.1 The CXX compiler identification is MSVC 19.0.24215.1 CMake Error at CMakeLists.txt:7 (PROJECT): No CMAKE_C_COMPILER could be found. CMake ...
  • drools-compiler module jci package JavaCompiler org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler:Eclipse Java development tools (JDT) 's ECJ(Eclipse Compiler for Java); org.drools....
  • [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 的问题, 原以为这是个个例, 源于同事粗心, 配置环境出问题造成, 后到百度查看一下, 遇到这个问题的不...
  • vue-loader&vue-template-compiler详解

    千次阅读 2020-02-29 16:29:34
    在 vue 工程中,安装依赖时,需要 vue 和 vue-template-compiler 版本必须保持一致,否则会报错。 Module build failed: Error: Cannot find module ‘vue-template-compiler’ 为什么二者版本必须一致呢?vue-...
  • 问题描述: 新建了maven项目,写了一个测试类,main方法运行报错`Error:java: Compilation failed: internal java compiler error` 已尝试的解决办法:在project和module中将JDK版本改成了1.8 且在setting中将...
  • JDK源码(17)-Compiler

    千次阅读 2019-12-25 22:55:57
    Compiler这个类被用于支持Java到本地代码编译器和相关服务。在设计上,这个类啥也不做,他充当JIT编译器实现的占位符。 放JVM虚拟机首次启动时,他确定系统属性java.compiler是否存在(系统属性可以通过System类的...
  • [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project mytest-web: Execution default-compile of goal org.apache.maven.plugins:maven-...
  • 然而当我用matlab自带的Application Compiler打包成应用程序后 ![图片说明](https://img-ask.csdn.net/upload/201707/23/1500786332_622510.jpg) 就会在运行到一半的时候“叮”的一声出错了,萌新能力有限,实在是...
  • configure: error: Invalid C++ compiler or C++ compiler flags 在安装 PCRE 软件时可能会报这个错误,这是因为系统缺失 gcc-c++ 库。CentOS下(我这里的环境是CentOS 7)root超级管理员用户执行以下命令,非root...
  • 情形: 解决方法:
  • jvm compiler种类

    2019-12-03 16:26:08
    client-compiler:这种compiler是主要跑在客户端本地的。特点是使用资源少启动快速。 server-compiler:跑在服务器上,因为服务器上程序本身是长时间运行的,而且对启动时间没有严格的要求。那么就可以牺牲启动时间...
  • opencv编译:The CXX compiler identification is unknown The C compiler identification is unknown 解决方法:Found this on Google... I would assume that in your case you would copy rc.exe and rcdll....
  • 解决方法
  • 安装design compiler的教程

    千次阅读 多人点赞 2020-05-03 12:33:52
    安装design compiler以及破解的教程教程开始design compiler工具介绍和所需环境准备工作启动installer安装软件安装DC插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、...
  • 我今天Android studio编译项目时报Could not download compiler.jar (com.github.bumptech.glide:compiler:4.9.0): No cached version available for offline mode错误, 我的Android studio版本是3.5,gradle版本...
  • 问题背景 今天在入门vue-route但是发现...[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use
  • 2.添加maven-compiler-plugin依赖 没有效果; 3.更换maven-compiler-plugin版本,无效; 4.配置 <id>custom-compiler <JAVA8_HOME>F:\jdk-1.8 无效; 5.修改mave setting.xml jdk信息,无效; 6.一个maven...
  • nginx安装错误:c compiler cc is not found

    千次阅读 2019-09-03 21:25:03
    今天安装软件nginx的时候遇到的报错:c compiler cc is not found 查了下网上的资料,解决方案也不复杂。 先说明下环境: 服务器:CentOS 7 nginx:2.3.1 原因是因为缺少 gcc-c++ 的包 解决办法很简单,执行:yum ...
  • [img=... ... 请问代码中:[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.CodeGenerator", "1.0.0.0")]表示什么意思?这个是编译器自动生成的代码吗?
  • Tcl与Design Compiler

    2020-02-11 11:16:08
    Tcl与Design Compiler (一)——前言 Tcl与Design Compiler (二)——DC综合与Tcl语法结构概述 Tcl与Design Compiler (三)——DC综合的流程 Tcl与Design Compiler (四)——DC启动环境的设置 Tcl与Design ...

空空如也

1 2 3 4 5 ... 20
收藏数 61,909
精华内容 24,763
关键字:

compiler