Compilation error: use of deleted function - c++

I am working through some example code from Lazar and Penea, Mastreing Qt5:
https://github.com/PacktPublishing/Mastering-Qt-5
I think I am starting to understand the code, but I am stuck with a compilation error in the method "addAlbum" in the class "AlbumModel", The offending line is
unique_ptr<Album> newAlbum(new Album(album));
which yields the error message
error: use of deleted function ‘Album::Album(const Album&)’
unique_ptr<Album> newAlbum(new Album(album));
^
I am using CMake 3.10.2 and cpp 7.5.0. I presume the github code is correct, so this error is a bit puzzling. Although there are a lot of "use of deleted function" discussions here on stackoverflow, I have not been able to determine the cause of the error.

Related

boost 1.72 get icmp::socket io_service for icmp::resolver

I updated my project from boost 1.67 to boost 1.72. Now I can't compile it because of the following:
I had code:
boost::asio::ip::icmp::resolver resolver(m_socket.get_io_service());
where m_socket is object of boost::asio::ip::icmp::socket. Compilation error in this case looks like:
Error C2039 'get_io_service': is not a member of 'boost::asio::basic_raw_socket'
Similar error was discussed here and the proposed solution was to call get_executor() method and then get executor's context. So I changed my code. Now it looks like:
boost::asio::ip::icmp::resolver resolver(m_socket.get_executor().context());
But still get compilation error:
Error C2039 'get_executor': is not a member of 'boost::asio::execution_context' (compiling source file PathMTUDiscovery.cpp) SocketsLib C:\Work\BuildFiles\boost\1.72.0\include\boost\asio\detail\io_object_impl.hpp 87
I tried to find something in Networking TS compatibility, but didn't find the solution here.
Anyone knows how to solve the error properly?

MSB6006 error when code used to work fine in visual studio C++

I'm getting the 'MSB6006 "CL.exe" exited with code 2' error. The problem is that my code used to work fine. The issue came when I tried to add another library from xtensor (the xtensor-blas) and I couldn't get it to work correctly. I just erased everything I tried to add and get a clean run, but it now fails every time.
While trying to compile the Error List says things like "C1083 fatal error: cannot open source file: 'files that I have deleted'". Whenever I stop the build, it then only gives the MSB6006 error.
It has become extremely frustrating since my code is identical to what it used to be and now doesn't work.
Is there any way around this?
Answer given by Quentin: There may still be references in the vcxproj file created by Visual Studio. Delete those references and it should work.

internal compiler error: in decode_addr_const, at varasm.c:2632

When I compile a project using cross compiler,I come across the following error:
internal compiler error: in decode_addr_const, at varasm.c:2632
Where can I find the varasm.c file?I searched the project directory and cross compiler directory,but I didn't find it.
Thanks for helpping,Light
The compiler maker has that file, and probably won't give it to you.
But as it seems to be an error in the compiler, you can either contact them / file a bug report, or try to avoid the error by changing your code a bit (which is a guessing game, as you don't know how you made it run into the error). Or use another compiler, if there are choices.

Inlining failed: function body can be overwritten at link time

I upgraded today from Ubuntu 12.04 which I think had g++-4.6 to Ubuntu 12.10 with g++-4.7.2. In my code I had a few functions marked as __attribute__((always_inline)). The reason for this was simply that profiling showed me that it increased the performance of the code significantly. It worked fine with g++ 4.6 but now with g++ 4.7 I get the error message:
error: inlining failed in call to always_inline 'void func_name(args)': function body can be overwritten at link time
I can't share my actual code, I've tried to narrow it down but when I change too much the error goes away, so that's not helpful. I'm interested in the root cause of this error message.
It wasn't my intention to answer this myself, but I accidentally found the answer a few minutes after I had posted.
The reason for this (cryptic) error message was that the function was not marked as inline, only __attribute((always_inline)).
For us, the issue was that we failed to also declare the function "static". "attribute((always_inline))" means, in plain text, "inline this and never include a function body" and the error message means "the compiler had to include a function body". In our case, since the function wasn't "static", it needed to be available for an external reference.

Really strange Eclipse error when attempting to Compile C++ code, looks like my code is never being deleted

I'm fairly new to c++ and decided to start learning by creating several basic projects. About halfway through I realized I was getting the same compiler errors when building my solutions, even though I was changing my code. I figured I had errors somewhere, so I decided to slowly undo until my errors went away. But, the same compiler errors were still there. I kept using undo until the only code that was left was:
#include <iostream>
These were the errors printed to my console:
../src/client.cpp:10:18: error: Note.h: No such file or directory
../src/client.cpp:12: error: 'bst' is not a namespace-name
../src/client.cpp:12: error: expected namespace-name before ';' token
../src/client.cpp: In function 'int main()':
../src/client.cpp:16: error: 'bst' has not been declared
../src/client.cpp:16: error: 'n' was not declared in this scope
The first error was due to a mispelling of "Node.h". I fixed the spelling mistake and the error persisted. But, I only have 1 line of code, and apparently line 16 contained an error.
HAS anybody ever had an issue like this before? I've been searching for a solution all night and havent had any luck. I'm running osx 10.6.8 (64bit) with a the newest 32bit version of eclipse. It started for no apparent reason. Thanks!!