Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i'm making a file's hashing app using a (HashLib++)
but when i test the (Library) with the Qt Creator it gives me an error

here is the pic of the errors

$Screenshot 148.png - Google Drive[^]

honestly i don't know what's make this error
i tried many things but no luck

What I have tried:

i tried a lot of solutions but no luck
Posted
Updated 22-Nov-16 2:23am
Comments
A7lam Lover 22-Nov-16 10:37am    
sorry not used to this kind of forums
i will be more careful next time for sure

thank you for your post
and sorry for the truobles about the pic...i didn't notice this
i ran the code & it run ok
but another problem occured...i hope you help me with it

the error caused by this line
hashwrapper *file_hashing = new md5wrapper();
displaying those errors
mainwindow.o:-1: In function `__static_initialization_and_destruction_0':error: undefined reference to `md5wrapper::md5wrapper()'error: collect2: error: ld returned 1 exit status

there's something else bothers me
when i want to save a syntax to a string the compiler display this message to me
error: conversion from ‘std::string {aka std::basic_string}’ to non-scalar type ‘QString’ requested
for example here
QString z1 = file_hashing->getHashFromFile(file01.toStdString());
the compiler complain but if i type just
file_hashing->getHashFromFile(file01.toStdString());
it don't complain...why is that ?
by the way i used the Library in (NetBeans IDE) & (Eclipse IDE)
and they gave me the same error

thank you in advance

1 solution

Please don't post external links to images. You only have a few lines of code and an error message that can be posted here.

If you had done that I would be able to copy and paste the code into my answer showing you how to solve the problem. But so you will only get a textual answer.

The error message is quite clear and a small arrow indicates that the passed argument file02 is the culprit. The following lines tell you that there is a candidate (I have to type it know!):
C++
virtual std::string hashwrapper::getHashFromFile(std::string)

You are passing file02 which is of type QFile but the the function getHashFromFile expects a std::string.

Assuming that the parameter is a file name, you can use file01 which is of type QString after creating a std::string from that:
C++
QString Z_01 = file_hashing->getHashFromFile(file01.toStdString());

[EDIT]
I missed that the result is assigned to a QString. So it should be:
C++
QString Z_01 = QString::fromStdString(file_hashing->getHashFromFile(file01.toStdString()));

[/EDIT]

[EDIT2]
Answering a new question raised as solution:
mainwindow.o:-1: In function `__static_initialization_and_destruction_0':
error: undefined reference to `md5wrapper::md5wrapper()'
error: collect2: error: ld returned 1 exit status

You must link with library containing md5wrapper.
To do this add the library to the the LIBS configuration in your Qt project file. See also Adding Libraries to Projects | Qt Creator Manual[^].
[EDIT]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900