I'm trying to use Cryptopp 5.6.2 on XPSP3 using VS 2010. New to this...
I need to use the mult-threading DLLs as that is what my application uses, so I changed all references in the Crypto++ project properties from /MT[d] to /MD[d]. All Crypto++ seems to build OK.
However, all is not happy with my C++ console app - I have the standard GetNewAndDeleteForCryptoPP and that seems to be called OK (remove it and cryptopp gives an error, include it and cryptopp doesn't print warnings).
All seems fine until I add in the line PKCS5_PBKDF2_HMAC<SHA256>. It compiles fine but causes two LNK2001 errors for unresolved symbols for CryptoPP::ThreadUserTimer::GetCurrentTimerValue(void) and
CryptoPP::ThreadUserTimer::TicksPerSecond(void).
Running out of ideas here - I can't paste the code due to arcane rules at the place I work, however I have included dll.h, cryptlib.h, osrng.h, aes.h, sha.h, hex.h, integer.h, modes.h and pwdbased.h.
Am I missing something blindingly obvious?
I was having this issue too, it doesn't look like that class is being exported. Adding CRYPTOPP_DLL to the declaration of ThreadUserTimer in hrtimer.h will fix it.
user1520427 provided you the answer. You need to add CRYPTOPP_DLL for a few classes and functions.
PKCS5_PBKDF2_HMAC<SHA256> is a header only implementation, so it does not need CRYPTOPP_DLL. See pwdbased.h.
However, ThreadUserTimer is not header only, so you need to modify hrtimer.h:
OLD:
00042 class ThreadUserTimer : public TimerBase
00043 {
00044 ...
00048 };
NEW:
00042 class CRYPTOPP_DLL ThreadUserTimer : public TimerBase
00043 {
00044 ...
00048 };
Related
I am using Resharper C++ with visual studio and I am getting an ambigous symbol error due to an apparent namespace clash. I get this error in Sd.cpp when, for example, I want to instantiate an enum Mode.
The enum class Mode is defined in Pins.hpp, which is included in Sd.hpp. However if I include Pins.hpp in Sd.ccp the ambigous symbol error pop ups. There is no problem compiling the project.
Could Resharper / Intellisense be not recognizing that Pins.hpp is the same file? The way #pragma once works is by the file path, so I don't know how that would happen.
I recently changed the include directories, so maybe this has something to do with the issue.
Any help would be appreciated.
Sd.hpp
#include "Pins.hpp"
Sd.cpp
#include "Pins.hpp"
Mode mode; //error here, Mode is underlined
Pins.hpp
enum class Mode : uint32_t
{
AlternatePushPull = GPIO_MODE_AF_PP,
};
EDIT1: Added code.
EDIT2: Renamed question to something more usefull
Turns out ReSharper looks into the entire VS solution when linting, not solely the project. Since in my solution I had some project which included the same libraries, but from a different location. Therefore ReSharper could not resolve the names.
The solution was simple: make sure that all projects all include the same files.
I built Qt from source (dlls) and am trying to build an application that uses the Qt dlls. I don't have a lot of experience with C++ so I'm running into what I'm sure is a very basic issue.
My builds are failing on the includes with errors like so:
Fatal error: QNetworkProxy: No such file or directory
Here is the g++ command I am using (I also used -L to add the correct folder to the lib path, but that also didn't work):
g++ -l..\..\wkqt\bin\QtCore4.dll -l..\..\wkqt\bin\QtNetwork4.dll -l..\..\wkqt\bin\QtWebKit4.dll -I..\include -Ishared -Ipdf -Ilib -Iimage -o ..\bin\wkhtmltopdf.exe pdf\*.cc lib\*.cc image\*.cc shared\*.cc
I tried in Visual Studio as well (assuming it wouldn't build, but I wanted to see if I could at least include the Qt dlls from there properly) and I am getting the same errors. Am I doing something wrong with the way I am compiling with g++? If I am linking with the Dlls properly then what is the proper way to use Qt functions from my code?
To clarify, I am not looking for how to properly use Qt. My question is: what is the proper way to use functions defined in any Dll from native C++ code? I apologize if this is a very basic question, but I'm unable to find a clear answer on Google and I don't have any experience with C++ and including third party libraries for use from C++ code.
DLLs can be used by dynamicly loading them and calling their used functions.
to call the exposed functions first define their syntax in the begining
suppose function is syntax is
BOOL MyFunction(int a,char* pszString)
then define syntax
#typedef BOOL (WINAPI *PMYFUNCTION)(int a,char* pszString)
then make object
PMYFUNCTION pfnMyFunction;
and get valid pointer by calling GetProcaddress after loadlibrarycall
HMODULE hlib= Loadlibrary("c:\\Mylib.dll");
if(hlib)
{ pfnMyFunction = (PMYFUNCTION)Getprocaddress(hlib,"MyFunction"); }
Hope this helps...
I encounter this error when I am trying to compile a c++ code via a Makefile.
error: expected initializer before ':' token
I have checked the compatibility of the compiler of my system
I also checked the paths etc. I also did some test; such as adding a semicolon after the 2nd declaration of class but didnt work. I have little to no experience with c++, the script is not even written by me; it is part of vtk library (Visualisation toolkit). Part of the script from where
the error generates is:
#ifndef __vtkProcessObject_h
#define __vtkProcessObject_h
#include "vtkAlgorithm.h"
class vtkDataObject;
class VTK_FILTERING_EXPORT vtkProcessObject : public vtkAlgorithm
{
public:
vtkTypeRevisionMacro(vtkProcessObject,vtkAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
I get the error in line 8.
Probably it is something really straightforward, but as I said I have no clue how this language works.
The VTK_FILTERING_EXPORT macro is defined in a header, and is largely there for Windows and/or GCC symbol visibility. You don't mention what version of VTK you are compiling, but using CMake to generate the Makefiles would ensure the correct include paths are set up. If this is Linux, and the GCC visibility functionality has not been activated you could define the macro to nothing, but I suspect you would hit many other issues once you got past this point in the compilation.
I have worked on a C++ project using a regular text editor. Later, I imported all the files to Eclipse to make it debugging easier.
In Eclipse a weird thing happens. It complains "Member declaration not found" even if I have included the header file. The header file has the function definition.
How do I fix this problem?
"Member declaration not found" is an error produced by the Eclipse static analysis tool (codan). If you get this error, but the compilation succeeds this is a false positive. Older versions of this tool are known to give some false positives, see for example this bug report. So I recommend updating Eclipse CDT to the most recent version.
Another thing that may cause this error is an unresolved include that prevents Eclipse from parsing a portion of your code correctly. Selecting Index -> Search For Unresolved Includes in the context menu of the project will give you the list of unresolved includes. See this answer for the details of how to fix it.
Here's an example:
class C {
void f(std::vector<int>&);
};
void C::f(std::vector<int>&) {} // Member declaration not found
The above example causes "Member declaration not found" error in Eclipse CDT even if you have <vector> included but unresolved (due to misconfigured include paths).
I also experienced this problem several times in Eclipse though building is successful. We can simply solve this problem by rebuild the C/C++ index in project menu. :)
I got this problem in Eclipse, but building in terminal was successful. So I just rebuild the C/C++ index in Eclipse:
Right click on the project -> index -> rebuild.
I noticed that "Member declaration not found" will report also when you create a class with a name that is already used or is a a keyword.
I found an error in my .cpp file that creates this message. I had namespace std { in the front of the file, and I placed new functions that I was creating after the closing } for namespace. Moving the closing } to the end of the file so that the defined files were now in the namespace fixed the error message.
Example that creates the error.
#include "MyStrFuncs.h"
**namespace** std {
MyStrFuncs::MyStrFuncs() {
// TODO Auto-generated constructor stub
}
MyStrFuncs::~MyStrFuncs() {
// TODO Auto-generated destructor stub
}
} // This ends the **namespace**
//Additional functions will now generate the member declaration not found error...
int MyStrFuncs::str2i(string strIn) {
int results;
istringstream convert(strIn);
if( !(convert)>>results) results = 0;
return results;
}
// Fix by moving closing } for namespace to here. Good luck.
Even with the CDT 9.2.1 and Eclipse Neon 4.6.3 "Member declaration not found" problems are reported.
As answered by Srijeyanthan, the following should resolve it:
Project > C/C++ Index > Rebuild.
I also experienced this problem while splitting source and header files in eclipse.I resolved this by "implementing methods" eclipse instead of manual typing and building the project.By implementing methods "inline functions" will be added to source file.
I followed the instructions to set up SFML here. When I check my /Library/Frameworks folder, all the SFML stuff seems to be there. However, when I check out a project my group is working on using SFML, and when I build, I get a ton of errors. These errors do not exist for my other group members. I think (some of) my errors are caused by SFML not recognizing sf::Input as a type.
Here is my code for one of the header classes in my project:
#pragma once
#include "Mover.h"
class InputMover : public Mover
{
public:
InputMover(const sf::Input* pInput);
//error here - expected unqualified-id before * token
protected:
const sf::Input* m_pInput;
//error here - ISO C++ forbids declaration of Input with no type
};
The parts without errors have been taken out. What do you think the problem is?
EDIT, SOLVED:
The problem was that I installed SFML with makefiles before I just did a copy-install. Some files were conflicting. I tracked down the installed files and deleted them. This seemed to fix the problem.
To use the SFML classes you need to include their definitions.
Add #include <SFML/Window/Input.hpp> to the top of your file.
Also note that to use SFML you must also link to the CoreFoundation, Cocoa and OpenGL frameworks, as well as to libfreetype.