如何排除某些CPP被链接? [英] How to exlude some CPP from being linked?

查看:112
本文介绍了如何排除某些CPP被链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:

我正在使用Visual Studio 2008,并且在
中有多个CPP文件 该项目.我想编译这些文件,但不链接它们,
因为它们都是具有相同功能的MATLAB接口函数
名称.链接这些功能会导致链接器抱怨,这是
没什么大问题.但是,我仍然想修复它.有什么办法
告诉链接器避免某些目标文件?

感谢

Hello everyone:

I''m working with Visual Studio 2008, and I have multiple CPP files in
the project. I''d like to compile these files, but not to link them,
because they are all MATLAB interface functions with the same function
names. Linking these functions cause the linker to complain, which is
not a big problem. However, I still want to fix it. Is there any way
to tell the linker to avoid certain object files?

Thanks

推荐答案

为什么不只是从项目中排除额外的模块?如果不链接模块,我看不到需要编译任何模块.
Why not just exclude the extra modules from the project? I cannot see any need to compile a module if you do not link it in.


您可以添加名称空间以避免函数名冲突.

当然,如果您知道会有碰撞,为什么不将它们命名为"MATLAB_xxxx"呢?这样,如果不使用它们,编译器将不会直接链接它们.

您还可以将函数放入lib中,并且在不需要时不链接它.
You could add namespaces to avoid the function name collisions.

Of course, If you KNOW there will collisions, why don''t you name them something like "MATLAB_xxxx"? This way, the compiler will simply not link them if they''re not used.

You could also put the functions into a lib, and simply not link to it when you don''t need it.


感谢您对我的答复.

我应该更好地解释一下:之所以要包含不需要链接的文件,是因为我想在Visual Studio项目中使用Visual Studio. Visual Studio提供了比MATLAB编辑器强大得多的编辑功能,因此我通常使用Visual Studio进行编辑和编译,然后使用MATLAB对其进行测试.因为MATLAB的接口函数具有固定的名称,所以每当我创建两个接口函数时,Visual Studio都会抱怨名称重复.

我将尝试使用名称空间方法,或者可能需要关闭整个链接过程的方法.
Thanks for replying to me folks.

I should have explained better: the reason I want to include files that I don''t need to link is because I want to use Visual Studio for my MATLAB projects. Visual Studio provides much more powerful editing functions than MATLAB editor, so I usually use Visual Studio to edit and compile, then test it using MATLAB. Because MATLAB has a fixed name for its interface function, so whenever I create two interface functions, Visual Studio will complain about the duplication of names.

I''ll try the name-space approach or, maybe I need a method to turn off the entire linking process.


这篇关于如何排除某些CPP被链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆