zoukankan      html  css  js  c++  java
  • [转]g++ 编译多个相关文件

    三个文件,一个头文件,两个程序文件

    /*
      d.h 
    */
    #include 
    <iostream>
    using namespace std; 

    class Dataset
    {
      
    public:
         
    int getdata();
    }; 
    /*
      d.cpp 
    */
    #include 
    "d.h" 

    int Dataset::getdata()
    {
      
    return 1231;
    /*
      out.cpp 
    */
    #include 
    <iostream>
    #include 
    "d.h"
    using namespace std;

    int main()
    {
      Dataset Ds;
      cout
    <<Ds.getdata()<<endl;
      
    return 1;
    编译: 
    [root@localhost code]# g
    ++ -o test.o d.cpp out.cpp
    [root@localhost code]# .
    /test.o
    1231
    [root@localhost code]# 

    编译成动态库 
    [root@localhost code]# g
    ++ -o d.o -c d.cpp
    [root@localhost code]# ar 
    -r d.a d.o
    ar: 正在创建 d.a
    [root@localhost code]# g
    ++ -out out.cpp ./d.a
    [root@localhost code]# .
    /out
    1231
    [root@localhost code]#
  • 相关阅读:
    ReentrantLock与synchronized的差别
    读TIJ -1 对象入门
    wikioi 2573 大顶堆与小顶堆并用
    开源 免费 java CMS
    UVA10972
    springboot5
    spring-boot4
    spring-boot3
    spring-boot2
    spring-boot1
  • 原文地址:https://www.cnblogs.com/killkill/p/1330200.html
Copyright © 2011-2022 走看看