一大堆的C函数,怎么编译成一个lib文件来使用 ?

nj_draker 2003-12-12 01:11:56
一大堆的C函数,怎么编译成一个lib文件来使用 ?

我下了jpge的解马程序,是很多的C函数,常见的做法是编译成一个LIB来使用?

我不知道怎么去创建一个PROJECT把他们编译成lib
...全文
142 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
broadoceans 2003-12-12
  • 打赏
  • 举报
回复
TO: hucsdn(hucsdn)

静态库是有代码的。


hucsdn 2003-12-12
  • 打赏
  • 举报
回复
windows下的.lib和dos下的.lib是不一样的,windows下的.lib只是一个输入表没有实际代码的。
carbon107 2003-12-12
  • 打赏
  • 举报
回复
完全同意hahu(网痞 -- 勿近) 的说法
做成dll文件
wanglh 2003-12-12
  • 打赏
  • 举报
回复
做成DLL吧,这样会自动生成LIB,以后只要将DLL和LIB拿出来就可以了。
hz张三 2003-12-12
  • 打赏
  • 举报
回复
写个*.cpp动态库,里面调用.h和.c的函数,我常这么干
broadoceans 2003-12-12
  • 打赏
  • 举报
回复
只要将其导入即可。
nj_draker 2003-12-12
  • 打赏
  • 举报
回复
都是 .h 和 .c文件
broadoceans 2003-12-12
  • 打赏
  • 举报
回复
其实就是创建一个Static Library Project
broadoceans 2003-12-12
  • 打赏
  • 举报
回复

It is a good idea to collect all the code files that you plan to include in the library in one directory called source. Remember that template code (such as apvector.cpp) does not go into the library.
Create a new project by selecting File, New, Projects, Win32 Static Library (VC++5.0) or File, New, Project Workspace, Static Library (VC++4.0/4.2). Provide the location and name for your library (for example aplib).
Add the *.cpp files that you want in your library to your project. To add a file to a project, select Project, Add to Project, Files (for VC++5.0) or Insert, Files into Project (for VC++4.0/4.2).
Compile and create the library by selecting Build, Build (VC++5.0/4.0/4.2). You now have your library created under the name you designated before.
Exit from the developer environment and copy your library, aplib.lib, to the directory where you want the library stored. Note, the library will probably be found in the Debug subdirectory in the directory created for you project.
hahu 2003-12-12
  • 打赏
  • 举报
回复
创建一个Win32 Dll
下面一个范例
cpp文件
#include "stdafx.h"

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
//有def文件的时候可以不用__declspec(dllexport)
//如果同时都有,而且在def文件里面指定了导出名,则该函数输出两遍
//一遍为导出名,一遍为原来的形式
//可用Dependendcy工具查看dll的这些函数
__declspec(dllexport) int AddInt(int x,int y) //c++函数
{
return x+y;
}

extern "C" __declspec(dllexport) float AddFloat(float x,float y)//可以被C调用
{
return x+y;
}

__declspec(dllexport) double WINAPI AddDouble(double x,double y)//C++函数,可以在Pascal中使用
{//WINAPI修饰其参数传递方式以及堆栈清空方式
return x+y;
}

extern "C" __declspec(dllexport) double WINAPI DivideFloat(double x,double y)//
{//可以被C,BASIC,Pascal调用
return x/y;
}

cpp同名的def文件
LIBRARY "SimpleWin32Dll.dll"

EXPORTS
Add1=AddInt @1
AddFloat @2
Add3=AddDouble @3
Add4=DivideFloat @4

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧