I know that all forums are full of such question, but I've tried few hooks, and they doesn't work (or I do them bad).
So, I've got:
main.cpp <- fawn.h <- connector.cpp (defenition) <- conncetor.h (declaration)
<- portl.cpp (def) <- portl.h (dcl) <- connector.h
with include guard (thanks to Igor Zevaka and jk), everything compiles, but doesn't link,
saying "already defined in main.obj" about all funcs., no metter are they static or not.
I've tryed already pulling the conncetor.h contents to connector.cpp, same way with portl.cpp (there was #include "connector.h" in it).
Thanks beforehand.
Does fawn.h include connector.cpp? (or do I read it wrong?)
If so this is your error. Now connector.cpp (itself) has a function bla() and main.cpp has same function because it includes (read: copy-pasted in) connector.cpp. And you are trying to link them together.
EDIT:
For the last error make sure FAWN::Sys::Connecter::getSocket(void) is implemented somewhere (and that cpp file it is in is linked in). Looks like it is just missing.
Make sure that you link properly against the required libraries of boost...
Check the dependencies here:
http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/using.html
Related
Is it possible to specify a C/C++ include path to a remote preprocessor server?
The point here is to have once central location for header files. This makes upgrades, version consistency, and a host of other things much better than people running all willy-nilly including different versions of things.
Minimal, Complete, and Verifiable Example
Typical include. On Linux, would default to /usr/include/ or the like; in Windows VS, to a location specified in the $(IncludePath) variable.
#include <iostream>
int main() {
std::cout << "hello, world" << std::endl;
return 0;
}
Now imagine that we set our include path as follows:
C_INCLUDE_PATH=192.0.2.17://usr/include;/usr/include;
The above would first check the remote server at 192.0.2.17 to see if the iostream library existed. Failing this, /usr/include would be checked.
This is a bit of a stretch to illustrate the point:
#include <192.0.2.17://iostream>
int main() {
std::cout << "hello, world" << std::endl;
}
Thanks, Keith :^)
Since you want version control anyway you could just use git (like thousands of other projects). So each user has a local clone of anything needed.
To answer the original question: No. I'm not aware of any preprocessor supporting such an include scheme.
I'm not aware of any compiler that retrieves include files or libraries remotely, so this is not something you can do directly.
The best you can do is have these dependencies on an NFS share that you can mount and then add that path to your include path.
I wouldn't put references to this in the code like that, and as dbush said, you'd have to enhance the preprocessor.
But there might be cute ways to do this within the Make system. That is, if you're using Make (for instance), you could add steps to the Makefile that force a refresh of data.
However, I would suggest this is WRONG because it's not just the include files that need to be fresh. If an include has changed, the related code has probably also changed, and you would need those changes, too. Your magic #include stuff isn't going to do a thing to make sure people have the right code / libraries that the includes are for.
I'm not sure why proper use of source code repositories don't already handle this for you.
I know this has been asked a thousands times, but I'm stumped. I've been looking all over for that last 3 days without a result. I keep getting this error and I can't figure out why.
I've added only the code that I have input / that matters. If I comment out my code the program compiles without a problem. What am I doing wrong???
CMakeFiles/brewtarget.dir/MainWindow.cpp.o: In function MainWindow::MainWindow(QWidget*)':
MainWindow.cpp:(.text+0xb145): undefined reference to yeastCellCounter::yeastCellCounter()'
CODE
mainwindow.cpp
#include "yeastcellcounter.h"
// a whole lot of stuff between these...
yeastCountDialog = new yeastCellCounter();
mainwindow.h
class yeastCellCounter;
// A whole log of stuff between these...
yeastCellCounter *yeastCountDialog;
yeascellcounter.cpp
#include "yeastcellcounter.h"
yeastCellCounter::yeastCellCounter(){}
yeastcellcounter.h
#ifndef YEASTCELLCOUNTER_H
#define YEASTCELLCOUNTER_H
class yeastCellCounter
{
public:
yeastCellCounter();
};
#endif // YEASTCELLCOUNTER_H
This are the INCLUDE_DIRECTORIES directive in cmakelist.txt
SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(SRCDIR "${ROOTDIR}/src")
SET(UIDIR "${ROOTDIR}/ui")
SET(DATADIR "${ROOTDIR}/data")
SET(TRANSLATIONSDIR "${ROOTDIR}/translations")
SET(WINDIR "${ROOTDIR}/win")
INCLUDE_DIRECTORIES(${SRCDIR})
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build.
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/QtDesignerPlugins")
Whenever you see a error of the type undefined reference to ... it is a linker error. This means that the compiler has completed it's work and all the object files have been compiled without errors. It's now time for the linker to put all the pieces together into a single file.
In your specific example, it says that it cannot find the definition of the function yeastCellCounter::yeastCellCounter(). From the code you have pasted, this function, albeit empty, is clearly defined in the file yeascellcounter.cpp.
It looks like your cmakelists.txt file is incomplete. You haven't specified which source files need to be linked together to create your final executable. You need to use the add_executable statement for this.
Here's a simple example
The problem is:
yeastCountDialog = new yeastCellCounter();
It should be:
yeastCountDialog = new yeastCellCounter;
(Notice the lack of parentheses). The default constructor is always called without parentheses. And also, you need to add "yeastcellcounter.cpp" to the list of cmake sources.
I am using XE3 and trying to construct a DLL with my third party component. Since it is a rather large project I will describe it then detail the question at hand.
I have multiple cpp files and multiple header files(classes in header files, functions in cpp files). I have everything linking and compiling fine UNTIL I put a CreateWnd() function into one of my classes
void __fastcall TICSByteEntry::CreateWnd(void)
{
TCustomControl::CreateWnd();
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) | WS_CLIPSIBLINGS);
}
Now it will compile with this code in it but when I put my component on a form and try to run THAT project it will give me an error
'[ilink32 error] Error: Unresolved external '__fastcall TICSByteEntry::CreateWnd() referenced from 'path'unit1.obj'
No other linking issues just that one and as soon as I comment it out everything works nicely as expected. When I was researching this online someone said it is having problems finding the entry point http://edn.embarcadero.com/article/27343. I tried what was recommended and no luck. Any one want to take a guess on what is wrong?
Instead of overriding CreateWnd() you should override CreateParams(). That way the window is created with the style you want and does not need to be changed after creation.
I think this would increase the quality of life when devving, but google came up with nothing and I couldn't find anything specific inside inside Netbeans either.
What I want is to start with this header:
class bla
{
public:
static void gfg(somearg asd);
};
Then I open the blank bla.cpp and pressed 'autoimplement'. After that, it would look like this:
#include "bla.h"
static void bla::gfg(somearg asd)
{
//TODO: implement
throw unimplemented("void bla::gfg(somearg) is unimplemented");
}
Anyone know of a tool like this?
I found http://www.radwin.org/michael/projects/stubgen/
"stubgen is a C++ development tool that keeps code files in sync with their associated headers. When it finds a member function declaration in a header file that doesn't have a corresponding implementation, it creates an empty skeleton with descriptive comment headers."
This looks like it does exactly what you want it to do.
Some time has passed and in the meantime the requested feature seems to have been implemented in netbeans. Refer to https://netbeans.org/bugzilla/show_bug.cgi?id=213811 , which also gives a description on how to use it:
Note:
Implemented CTRL+SPACE.
IDE suggest implementing of class method if CTRL+SPACE was pressed:
- inside file that already has at least one method definition
- between method declarations
Ok, I've searched quite a bit, but seem unable to find an answer or example for how to achieve this.
Basically, I have an app that is designed to be portable (built using VC++ in VS2010, but no MFC or managed components, raw WinAPI). I have Lua 5.2 built into it and allow the user to write scripts inside the application. I have multiple glued functions which are exposed to the Lua scripts which handle various WinAPI calls.
However, what I'd like to be able to do is allow the user to write a script in which looks something like this:
require[[Alien/alien]]
local mb = alien.User32.MessageBoxA
mb:types{ 'long', 'long', 'string', 'string', 'long' }
print(mb(0, "Hello World!", "Test", 64))
I simply cannot seem to find a way to do this. I do not want to require the user to install Lua for Windows and, ideally, there be no core.dll and struct.dll from alien; when I tried to do something with those DLLs in ./alien/, it was crashing in Lua5.1.dll because I had LuaForWindows installed, I uninstalled LFW, and then it just states that Lua5.1.dll is missing. I have Lua 5.2 built into my app, so obviously the core/struct DLLs from the Alien rock are expecting Lua5.1.dll to be in the path.
I made a worthless attempt to try to including the Alien src into the project, but doesn't seem to work that way either.
Any ideas would be greatly appreciated. I'd prefer it all be contained in my app, but I'll settle for a solution which involves including the libraries in my project to build and bundle in the distribution if that's the only alternative.
Thanks!
UPDATE:
Ok, thank you Ben Voigt! I think I'm almost there. I've pulled in core.c and struct.c and made sure all the paths are there for libffi. Everything compiles without issue, until I try to call luaopen_alien_core in core.c (the alien.core src file), claiming the identifier is undeclared. I've tried to declare the function signature in my separate source file that's trying to make the call, the compile gets further, but fails complaining of an unresolved external.
Clearly this is likely now a general C++ issue (as I'm only a novice in this area). Here's the general idea of what I have:
//core.c (from Alien project)
(...)
int luaopen_alien_core(lua_State *L) {
alien_register_library_meta(L);
alien_register_callback_meta(L);
alien_register_function_meta(L);
alien_register_buffer_meta(L);
lua_getglobal(L, "alien");
if(lua_isnil(L, -1)) {
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setglobal(L, "alien");
}
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setfield(L, -3, "core");
alien_register_main(L);
return 1;
}
//mysource.c (the file attempting to call luaopen_alien_core(L))
void initLua()
{
L = luaL_newstate();
luaL_openlibs(L);
luaopen_alien_core(L);
(...)
}
This fails to start compiling, issuing the error:
error C3861: 'luaopen_alien_core': identifier not found
Which makes sense, so I add the following line to myheader.h:
int luaopen_alien_core(lua_State *L);
This compiles, but fails to link with:
error LNK2001: unresolved external symbol "int __cdecl luaopen_alien_core(struct lua_State *)" (?luaopen_alien_core##YAHPEAUlua_State###Z)
I've tried several things I can think of, with my limited experience, but nothing will satisfy this error. I even tried to move the contents of core.c into mysource.c, but that creates a whole different mess and seemed to be the wrong way to go as it is.
I'm hoping, and imagining, this is something really stupid, but I'm just not sure how to get it to call luaopen_alien_core, which seems to be the final piece I need.
Thanks again!
}
I imagine that the require directive both loads a dynamic library and adds its contents to the active Lua engine.
By linking alien directly into your code, you obviate the need for the dynamic library. But the content enumeration code won't have run, and you can't use require to run it, or else it'll go looking for a DLL file (along with all the DLL dependencies).
So, you should find out what functions that require directive calls after loading the DLL, and call those when creating a Lua engine. Then it will neither be necessary nor allowed for the script to start with require [[Alien/alien]], but Alien objects will be available.