我试图用Cmake实际构建PhysFS库,我使用的是Code :: Blocks mingw makefile.我可以在我的项目中导入,我可以在技术上声明PhysFS_init()函数(虽然这给我的参数错误太少)但是当我添加一个参数时它告诉我PHYSFS_init是一个未定义的引用.
这对我来说听起来很愚蠢,当你没有争论的时候你怎么能认出它,但是当我添加一个参数时假装它不存在?我已经运行了两次CMake,但我只是得到了这个:
[...]\src\main.cpp|20|undefined reference to `PHYSFS_init'|
Run Code Online (Sandbox Code Playgroud)
代码,如果有必要(只是一点,其余的是无关紧要的):
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include "Globals.h"
#include "GameStates.h"
#include "GameWindow.h"
#include "GameMenu.h"
#include <physfs.h>
int main(int argc, char** argv)
{
///<|===================| Classes & Declarations |===================|>
sf::Event ev;
sf::RenderWindow winMain ( sf::VideoMode( WindowWidth, WindowHeight, 32 ), WindowTitle );
sf::Image Icon;
GameStates gameState;
GameMenu TitleMenu;
MenuButton buttons[4];
PHYSFS_init(NULL);
Run Code Online (Sandbox Code Playgroud)
为什么会这样?为了能够在我的项目中使用PhysFS,我该怎么办?我用CMake构建了库,我包含了我需要的库,并且我尝试初始化PhysFS,这给了我一个错误,让我觉得C++编译程序的方式很愚蠢.