我正在尝试创建一个共享库文件。从我的C文件中调用我的C函数从Python。我发现一些网站说,我们可以使用以下命令:
cc -fPIC -shared -o my_functions.so my_functions.c
但是,我不确定在哪里需要运行这个命令。我试着在Visual Studio Code的终端上运行这个,但得到了以下错误:
> PS C:UsersmeDocumentsCProgramming 903_> cc -fPIC -shared -o my_functions.so my_functions.c
cc : The term 'cc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ cc -fPIC -shared -o my_functions.so my_functions.c
+ ~~
+ CategoryInfo : ObjectNotFound: (cc:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
有人知道运行这个命令的正确方式或正确平台是什么吗?说明一下,我使用的是Windows。这是我提到的网站:https://www.journaldev.com/31907/calling-c-functions-from-python
cc
为编译命令。你当前的shell (Powershell)在你的Path中找不到cc
你需要安装一个编译器(比如gcc)或者将你已经安装在你系统中的编译器添加到你的Path。