Why can't a "procedure entry point could not be located in dll" when I definitely put it in?
Asked Answered
R

4

9

I have a really vague problem, but I hope someone can help with it. I was modifying a C++ project and yesterday it was still working, but today it's not. I'm pretty sure I didn't change anything, but to be completely sure I checked the project out from SVN again and I even reverted to a previous system restore point (because this is a work computer, it sometimes secretly installs updates etc.). After succesfully compiling it, the program can start up, but after I interact with it, I get this error: The procedure entry point ?methodName@className@@UAEXXZ could not be located in the dynamic link library libName.dll.

I've searched the internet, but most people's problems seem to be caused by an older version of the DLL being used. I searched my computer and there is no older version. If I delete the correct version, the application doesn't start. If I then recompile the project, the DLL is created again, so I'm both pretty sure that the application is using the correct DLL and that the compilation is creating it. If I introduce syntax errors into the method that the error refers to, the project refuses to compile, so I guess this means that it is also compiling the files that contain the method.

Basically I don't know anything about DLL's, linking, etc. so I would greatly appreciate it if anybody has an idea as to why the functions that are very clearly defined in the project are all of a sudden not making it into the DLL anymore. I know this is vague and if any more information is required I will gladly provide it. Thanks!

Update: I have tried the given suggestions, but I'm still stuck. __declspec(dllexport) is apparently not used in the entire project. Opening the DLL with Dependency Walker shows me an empty top right section and the section below it lists the function from the error message. If I check Undecorate C++ Functions it looks fine, but if I don't I get the weird question marks and @s from the error message and there appears to be a difference at the end:

?methodName@className@@UAEXXZ
?methodName@className@@UAEXH@Z

Perhaps this is the problem, but I have no idea what it means, what may have caused this and what I can do about it.

Ramberg answered 3/12, 2009 at 17:57 Comment(1)
Have you tried adding /Wall to VC++ compiler options? Might give a hint...Segalman
R
1

I feel a bit stupid, but I found the answer. The application (exe) I was using apparently loaded a second, different dll which had a dependency on the one mentioned in my original post. This second dll was still expecting the old functions and also needed to be recompiled against the updated dll.

Many thanks to the people who tried to help me here!

Ramberg answered 8/12, 2009 at 17:0 Comment(0)
W
9

Are you actually using __declspec(dllexport)? My guess is no -- without that declaration, that function will not be exported by the DLL (or in other words, programs loading that DLL will not have access to functions without that declaration).

Also, try using Dependency Walker to see exactly which functions your DLL has made available.


The fact that __declspec(dllexport) isn't used in function declarations is okay -- most of the time, it will only be used once in a single header file, like

#ifdef MAKING_DLL
#define FOO_API __declspec(dllexport)
#else
#define FOO_API
#endif

So that if you have #define MAKING_DLL before that section, all functions that are declared like FOO_API int BakeACake() will be exported based on whether MAKING_DLL was defined. It's possible that the project was expecting MAKING_DLL (or its equivalent) to be defined on the command line, depending on the project type built (something like /DMAKING_DLL; or you might even need to define FOO_API yourself like /DFOO_API=__declspec(dllexport).

The empty top right section in Dependency Walker just means your program isn't linking against the DLL's corresponding .lib file. That's okay, it just means you are using LoadLibrary or LoadLibraryEx to access functions in the DLL.

Another fairly likely scenario (based on the fact that the mangled names are different) is that the program was built using a different version of Visual Studio than 2008, which you used to build the DLL. Unlike plain C, there's no standard binary interface for C++, which means that you have to use the same compiler to build the program and the DLL when you are using C++ classes in the DLL. If you can, try rebuilding the program in VS2008, or try rebuilding the DLL in the same version of VS as the program was built.

Width answered 3/12, 2009 at 18:0 Comment(1)
Thanks for your answer! I've tried looking at your suggestions, but I'm still stuck (see the update to my question). If you have more suggestions, that would be great!Ramberg
G
2

Download dependency walker and open your dll using this tool. It will show a list of exported functions from your dll. Check whether the above said method is part of the expected functions. If it's not, then it means you accidentally removed __declspec(dllexport) for one of the classes in that dll.

Googol answered 3/12, 2009 at 18:4 Comment(2)
Your answer appears to be exactly the same as the poster above you, but thanks anyway! I tried the suggestions, but I'm still stuck (see the update to my question). I'd be thankful for more help!Ramberg
@Jordi: That is the first thing people will do when faced with this problem. I guess we started typing together and s/he completed before me.Googol
R
1

I feel a bit stupid, but I found the answer. The application (exe) I was using apparently loaded a second, different dll which had a dependency on the one mentioned in my original post. This second dll was still expecting the old functions and also needed to be recompiled against the updated dll.

Many thanks to the people who tried to help me here!

Ramberg answered 8/12, 2009 at 17:0 Comment(0)
M
0

Using information of the posts above I found simple general solution. All you need to do is open programs executable with dependency walker, look for the missing functions, look what dll's are using it, find the project which builds that dll and rebuild it.

Milone answered 18/4, 2011 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.