I have no experience with C/C++. I do not know how to even open files. I am working with SLN files in Visual Studio 2019 trying to compile a program I took off of GitHub (https://github.com/Marlowe97/Expected-Force).
I get these two errors (LNK2005, 'main already defined in TestExpectedForce.obj, and LNK1169 'one or more multiply defined symbols found') when trying to compile the Expected Force solution. The only changes I've made from the downloaded files are the ones directly stated in the instructions on the GitHub page of the program.
Is there someone who can tell me what to look for in as plain of a way as possible? I know basic Python and R so I understand some terms, but I know nothing about C so no other posted solutions to these errors make any sense to me. I'm already pretty concerned that I'm getting errors after following the step by step instructions from GitHub on what seemed to be a pretty basic task.
It's a strange package...
The functionality is provided as a library, to be compiled into your own project.
There are TWO test source files: TestExpectedForce.cpp and TestExpectedForce.cpp, each of them contains main().
They should be in their own projects (possibly, under the same solution).
To quickly move forward, just remove one of the test files from your solution.
Related
I'm struggling with the Code::Blocks IDE when programming in C.
I use one custom library, named "main.h".
Yesterday, when I begun working on the library, the program compiled without errors. I even put some functions written on the library on my source file and it built and ran fine.
Today, when trying to recompile the whole project after some modifications, appeared the "undefined reference" error.
I searched it over on this site, I tried to follow the steps another user proposed but now, instead of the "undefined reference" error, appears the "cannot find -l[filename]".
I tried to collect information about this error on this site as well but, I understand, it's a OS problem and, apparently, never happened to other Code::Blocks users.
I use Windows 7 64 bit, in case this is the problem.
Can you please help me?
Try to put fullpath to library in build options of your project and be sure to put it in the right build scheme(Debug/Release) or both to be sure.
However it is quite strange name for library - "main.h". Is it "main.h.dll" or what? Maybe it is header file? If it is so and you put implementation of you functions in .h file and not in .c, some errors could occur.
Though this is my first question on the StackOverflow, I consider myself a long time member of the community.
Considering myself as a pre-intermediate programmer, I'll try to be as specific as possible.
I'm writing a Python package that uses a C dll to load image files with ctypes. I'm using Python 3.3.5 32bits version on Windows 8 x64. I had to build the dll from the C code. The dll is stb_image.h which is available in GitHub. I used Code::Blocks version 13.12 with the GCC compiler. The dll seems to have built fine.
By my definition, the dll is must be in the same folder as the py code file that wraps its functions, but when ctypes attempts to load the dll an exception is raised: the [in]famous WindowsError: [Error 126] Module not found.
I've found several similar questions and attempted to glean from their solutions by
adding the dll path via os.environ['PATH']
adding the dll path manually in the Path environment variable
changing the current working directory with os.chdir()
using the file module attribute to locate the library
none of these solved the issue
The stb_image library itself has no dependencies so I don't understand why windows can't find it since the dll is where it should be and the path addresses it's exact location. And, of course, there's a lot of other ways to get the job done: PyGame, pySFML (which also uses stb_image), PIL, PyPng, PySDL, you name it, but I'm doing this mostly for learning purposes.
At the writing of this question, something popped up in my head (which may or may not have any relation with the problem): whenever I compile and link programs with GCC and try to run them, I got a message box telling me that some dll (libgcc.dll or something like that) was not found. Could that be the reason Windows can't load stb_image.dll?
I tried everything my experience allowed me to do to solve it but it was not enough. Would you guys, please, give me a light on this?
PS.: Sorry for any bad english. I'm natural from Brazil.
for a lab we're suppose to work on I need to set up Cuda with Visual Studio 2012 and run some tests. What I've done:
Install Cuda 5.5 + Edit build configurations.
Visual Studio 2012 is installed.
In the project, right click -> Build Configurations and choose Cuda 5.5
Project -> Properties -> VC++ directories: Set include/lib directories from Cuda directory.
Now, I was under the impression that after doing all this I should have no need to put "#include cudafiles" in my classes, they should be automatically imported, no?
I'm not getting the following as undefined:
cudaFree
cudaError
HANDLE_NULL
The following as 'device is not a type name'
__device__
And __global__ has no storage class or identifier.
I've spent hours and hours and hours trying to get this to work, following tutorials online, but I just can't get it to run properly. The code I'm using can be found here:
https://bitbucket.org/mrfright/cuda_by_example/src/bd759a6527ffa1b88420fc09acbc52f88c0587d2/appendix_a/?at=default
You can see in those files only 'lock.h' and 'book.h' are being included. I am including both of those.
Also, I am very new to C and VS so I may be leaving out a lot of important info.. please advice me to anything you may need to help assess this!! Thanks!
a few key points extracted from the discussion in the comments:
when installing CUDA on windows, make sure VS is installed first. The CUDA toolkit install modifies VS to make compiling CUDA code easier. If VS is not installed or you install/reinstall later, you won't get these modifications.
follow the instructions in the getting started guide including the running of sample projects followed by the building of sample projects. The first point at which you have trouble will be instructive as to what the actual problem is. If you just jump to the end (i.e. trying to create/build/run your own project), it won't be clear where the problem is.
You can build your own CUDA project either by opening an existing project and modifying it, or else creating a new project using the wizard. When just starting out, it may be easier for new users to try modifying an existing project first.
Be aware that various CUDA programs may require a specific compute capability. This means both that your device must support that compute capability, and that you are compiling correctly for that compute capability. You can determine the compute capability of your device by running the deviceQuery sample. You can change the compute capability that you are compiling for in the VS project CUDA settings.
when writing your own CUDA code, and definitely if you are having trouble, you should always do proper cuda error checking
Also be aware that asking questions about how to get drivers loaded, etc. and sorting out machine configuration issues, will very often be considered off-topic for stack overflow. Many questions like this get close votes for this reason.
I've been trying to compile balsa the email reader on ubuntu (i'm new to the whole process of compiling an open source project directly from sources.
so i did the whole configure and make but then I ran into this problem:
error: unknown type name 'gpgme_decrypt_result_t
after doing a little research on the error code.. it turns out that it belongs to gpgme a scary looking encryption library..
what do I do in this case? i hope i'm not expected to go in the code and debug stuff am i?
update:
this question is related to this other question here on the ubuntu forum
Unfortunately, you may be required to delve into the code to figure out why something doesn't build!
In this case however the answer is probably quite simple. The main reasons I would expect a symbol from an external library to not have been defined are:
The library header files do not exist on your system
You have the wrong version of the library header files on your system
The headers exist, but the compiler is not looking in the correct place
Clearly the solutions are similar: you will need to install the correct version of gpgme's header files for this software in the right place. Note that having the library itself installed is not the same as having the headers. In Ubuntu this is evident due to the presence of -dev packages which are the package's header files, and if you look through the repose you will find libgpgme11-dev. I suggest you start by installing this, which will eliminate point 1 above. If it still doesn't work, you'll need to start investigating the other two possibilities.
Currently we are looking at moving our development environment from CodeWright (which has long since been abandonned by Borland) and moving to Eclipse. We are using Eclipse for Perl, PHP and some Windows C++ development with much success.
The issue comes up however with our embedded environment which uses - in the makefile - some defines that Excel does not seem to understand. Here's an example (whith values changed to protect the guilty):
F_FOO unsigned char foo(ptr *this)
{
}
where F_FOO is defined in the makefile as
F_FOO=#foobar
Eclipse will highlight the F_FOO and flag it as a syntax error. That causes all kinds of grief with traceability.
To some exctent this also happens with some code in Builder C++ where Eclipse does not know how to handle the keyword __fastcall.
Any help on this (I know we can't be the only ones running into this issue) would be highly appreciated.
We tried the #defines in the header directive but because of the size of the project as well as the sheer number of files, that turned out to be a not too practical approach.
Tooling around Eclipse we found a solution that works for us and it is detailed below:
Right click on the project in question.
Select Properties at the bottom of the resulting menu.
Expand C/C++ Geneeral
Select Paths and Symbols
Under Symbols add the offending symbol (leave Value blank)
That did the trick for us. We have now restored full traceability for our software.
You could make a header file that is included with #defines for the things Eclipse doesn't know about. Then as part of your build have it use an empty version of that header file so it doesn't actually use those defines.