简体   繁体   中英

Linking Error in C++ development in Visual Studios 2008

I am doing c++ porting/development in visual studios 2008. I am getting the following issues.

1) Variable sized array not allowed. 2) Linking error for any of the undefined functions of the class even if they are not referenced.(error LNK2001: unresolved external symbol "public: virtual void __thiscall ...)

I think these are related to the version of the c++ language VS2008 support.

I am trying a compile and link large c++ codebase. I cannot substitute variable sized array with new/alloc. Please give me solution so that I can use the existing code.

Can anyone please help me sort this out?

But the following code works fine in the same VS2008

class Hello
{
public:
    int a;
public:
virtual void add();
};
class bye : public Hello
{
public:
    int y;
public:
    void add();
};

int main()
{
    std::cout << "got";
}

Where am I going wrong?

Virtual functions are considered "used" if you have a single instance of a class created anywhere. Your link error indicate that certain virtual functions are not implemented. As the error list all of them by name it must be a trivial task to locate them, end figure out if you failed to include some code, compiled with different options, or they were indeed unimplemented in the source place -- in which case you can just add blank implementations calling terminate.

For the VLA problem: that extemsion is not present in VS2008, period. Even if you wait some years and VS201y will implement the new VLA-like thing in C++14, it will not go back to your chosen compiler. (kinda weird if you ask me to chose a 5-year old bug-ridden beast that has dropped of support long ago, instead of the current...)

But std::vector does almost the same as VLA, and if you find difference you can write a beter wrapper or a few adapter functions. The place of memory allocation is not something you can discover legally in the program anyway. In case you'd hit some performance bottleneck, that is doubtful from such a change, you can rearrange a small portion of code.

如何使用std :: vector替换数组?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM