1

I use visual studio to do load a 3D model with opengl and Assimp, so I imported Assimp in my project without any problem. I want to make a class called "Model" that can load a 3D model from a file (I am following the tutorial from learnopengl.com), but visual studio 2019 says "; expected" at some point :

#pragma once
#include "Shader.h";
#include "Mesh.h";

#include <Importer.hpp>
#include <scene.h>
#include <postprocess.h>

class Model
{
public:
    /*  Functions   */
    Model(char* path)
    {
        loadModel(path);
    }
    void Draw(Shader shader);
private:
    /*  Model Data  */
    vector<Mesh> meshes;
    string directory;
    /*  Functions   */
    void loadModel(string path);
    void processNode(aiNode* node, const aiScene* scene);
    Mesh processMesh(aiMesh* mesh, const aiScene* scene);
    vector<Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type,
        string typeName);
};


void Model::loadModel(string path)
{
    Assimp::Importer imp; // "; expected"

    int a; //works fine 
    Shader shader("test", "test"); //works fine

}

Look at the "load model" function, visual studio says "; expected" and the imp variable is highlighted in red. I am following this tutorial : https://learnopengl.com/Model-Loading/Model

Update :

#pragma once

#include <Importer.hpp>
class test
{
    void f();
};

void test::f()
{
    Assimp::Importer imp();// "; expected"
}

Same error here

UPDATE 2 : Now it works but I don't understand why I had an include folder with all my assimp include files inside, and my visual studio project add linked all include file by linking my folder named "include". So I was linking $(SolutionDir/ExternalLibs/assimp/include)

But for some reason, after hours of trying to figure out the problem, I panicked and created a file named "assimp" inside my include folder, then I put all my include files from the assimp library inside my new folder. So my path to my include files is now "ExternalLibs/assimp/include/assimp"

And now it works, I don't know why. I include like this :

#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

Instead of this :

#include <Importer.hpp>
#include <scene.h>
#include <postprocess.h>

I don't know why it works, because firstly, every tutorial I have seen doesnt do that, AND before anyway I could instantiate other object specific to this library (aiNode, aiMesh, aiScene like you can see in my code) without any problem. Even inside a function, like for the Assimp::Importer.

So now I don't have the "; expected" error. I guess its a bug, and I don't know if it comes from the library or visual studio

Zul Huky
  • 331
  • 4
  • 24
  • 1
    If you follow the tutorial, why don't you make `#include #include #include ` according to this tutorial? – 273K Oct 13 '19 at 16:42
  • It doesnt recognize the library if I put "assimp" before – Zul Huky Oct 13 '19 at 16:52
  • 1
    It seems you installed the Open-Asset-Importer-Lib improperly. – 273K Oct 13 '19 at 20:31
  • I reinstalled the lib several times following exactly the instructions (https://www.youtube.com/watch?v=W_Ey_YPUjMk) and Assimp:Importer does not want to compile. – Zul Huky Oct 15 '19 at 18:56
  • @ZulHuky You need to teach visual studio how to find the assimp files, by adding search paths for include directory. I do not have visual studio, but you can see some tutorials here: https://stackoverflow.com/a/15975661/2293156 – Amadeus Oct 17 '19 at 12:51
  • @Amadeus I did that, I already did it for other library without any problem (glfw, glew, glad, soil2). I checked every paths and entries hundred times and it didnt worked. I uninstalled visual studio and restarted a new project. Then I did exaclty what I did for my old project, and now assimp is working, I can import a 3D model without any issues. Like I said, I think it is just a bug from visual studio – Zul Huky Oct 17 '19 at 13:30

0 Answers0