【问题标题】:How to compile c++ to Window's .net Dll file in Ubuntu如何在 Ubuntu 中将 c++ 编译为 Window 的 .net Dll 文件
【发布时间】:2015-10-27 07:35:59
【问题描述】:

现在我可以使用提供的make文件编译成功,现在我想将项目编译为dll文件,我应该如何修改make文件以便我可以在windows .net框架中使用dll文件?我想要的是一个 .net dll(不仅仅是一个 win32 dll)。

make 文件是:

default: all

# -------------------------------------------------------------------
# Change the path to Z3 4.1.1 accordingly
# The directory indicated by this path should contain "lib" and "bin"
# e.g. "/home/z3_src_4.1.1"
#      "/home/work/tool/z3/z3_src_4.1.1"
# -------------------------------------------------------------------
Z3_path = ../z3

JUNK = S3
SOURCE = strTheory.cpp testMain.cpp
INCLUDE = $(Z3_path)/lib
LIB = $(Z3_path)/bin/external

all: $(SOURCE)
    g++ -std=c++14 -O3 -fopenmp -static -I$(INCLUDE) -L$(LIB) $(SOURCE) -lz3 -lrt -o S3 -Wall
    @echo ""

clean:
    rm -f $(JUNK)

【问题讨论】:

  • 将静态替换为共享。
  • dll(动态链接库)是Windows下使用的名称;在linux(unix?)上,它被称为so(共享对象)
  • 有很多关于如何在Linux中创建共享库的教程,随便搜一下就可以了。
  • @PaoloM 因为我想在windows中使用,我该怎么做
  • 好的,那么答案是你需要交叉编译代码,我真的不知道如果没有特殊的工具来生成DLL是否可能。您也许可以使用 MinGW for Linux 之类的东西来做到这一点。

标签: c++ .net ubuntu gcc dll


【解决方案1】:

在 google 中搜索“linux 上的交叉编译器”。这个问题已经问了好几次了

Create a library or DLL in Linux and using them on Windows

How to compile for Windows on Linux with gcc/g++?

【讨论】:

  • 我想要的是一个.net dll(不仅仅是一个win32 dll)。抱歉,我的问题没有说清楚,我已经修改了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-16
  • 1970-01-01
  • 2018-05-10
相关资源
最近更新 更多