chipmunk and codeblocks undefined reference error - c

I built chipmunk with the codeblocks project file and have linked to the libchipmunk.a file but I am still getting 1 error when trying to built the hello world sample file.
Undefined reference to 'cpBodySetPos'
Any body know how to fix this?

Its either you haven't linked the libchipmunk.a file properly in the linker tab or if it an older version of chipmunk, then the generated libchipmunk.a file does not contain the declaration/definition of the cpBodySetPos().
To link libchipmunk.a file:
Open the project file.
Then right click on the project (from the left pane) and click "Build Options."
In the window, on the left there should be , Release, Debug.
Select your project name, then click on the "linker" tab.
From there, add the library into link libraries.
If you're using windows, you'll have to manually find the library, or in linux, just type "chipmunk" and gcc/ld should do the rest for you.
Also do refer this link to find out if you are generating the libchipmunk.a file properly for codeblocks and from the latest version of chipmunk.

Related

Nested static libraries in Visual Studio?

I have a static library for a Vector implementation in C.
I am now making a new library that is going to rely on the Vector in order to function property. This new library is called String. Both are static libraries created in Visual Studio with their own .c and .h files.
I do the following just like I would when referencing any other static library
Create new static library. Create .c and .h files in it.
project -> properties -> C/C++ -> Additional include directories and set as the folder that contains the .c and .h files for my Vector
File -> Add -> Existing Project and set the .vcxproj file of the Vector project.
In my solution explorer, I went under my String solution and right clicked References and then check-marked the Vector box that shows up.
At this point, my String is now correctly able to see Vector.
The problem
When I open a new project, repeat those same steps except with String as the target library, I get the following error:
Severity Code Description Project File Line Suppression State
Error MSB8006 The Platform for project 'C-DataStructuresLib.vcxproj' is invalid. Platform='HPD'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Platform. CStringLib C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.InvalidPlatform.Targets 21
The line:
This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Platform
Is correct because that's exactly what I'm trying to do. How can this be fixed?
Are you trying to compile as 64-bit project?
Check in the property page the section: Linker -> Advanced -> Target Machine

header .h file not found error in Xcode 7

I am working on a project which includes CLucene library. It Builds and runs fine on Xcode 6 but after upgrading to Xcode 7 it gives an error -Clucene/stdHeader.h file not found.
Any help appreciated.
Fixed it
Select the project in the navigation panel and select target to TechEFB, Then switch to "Build Settings" tab.
Goto "Search paths” -> “User Header Search Paths"
Double click the value and add the following paths of the library or file:
/Users/Lax/Documents/MyProj/subfolder/Libraries/Clucene/include/shared
/Users/Lax/Documents/MyProj/subfolder/Libraries/Clucene/include/core
NOTE: this is an absolute path. You will need to change the first part to find where your Xcode project is and replace the path.
In the same page, click on ALL option, search for “Bitcode”. Xcode will filter the options for you.
Set “Enable Bitcode” to NO
I had the same error in react-native. Was trying to add Crashlytics to my application following this crashlytics-tutorial and ended up failing the build due to RCTLog.h not found.
Using Lax's solution I also ended up in "Header Search Paths" and added the following search path
$(SRCROOT)/../node_modules/react-native/React/Base
Then it was able to build!

Using external static library in LPCXpresso

I am using the LPCXpresso IDE to program my microcontroller to use the libjpeg library for a particular application. However, I cannot seem to get the LPCXpresso IDE to recognize libjpeg. The way I see it, there are two options:
1) Take the jpeglib.a file, include it as an external library, and then attempt to import jpeglib.h. I have tried this, at the IDE still does not recognize jpeglib.h.
2) Create a new static library from the libjpeg source code. Is this my only option? It seems a bit excessive.
Any tips regarding adding/linking external libraries in LPCXpresso would be greatly appreciated. Thanks!
You can easily add a library to Eclipse/LPCXpresso by creating a new project (not a C project or a LPCXpresso project but a 'normal' project) by clicking File->New->Project. Name is as you wish, let's say 'JPEG'. Add your library file to it under the folder 'lib' (you have to create the folder first). Call the library file 'libJPEG.a'. Also include the header file under the folder 'inc'. It is not mandatory to create these folders by the way, but it makes it all more organised.
The edit the properties of the project that's needs to include the header and library. Right click the project and choose properties. Go to C/C++ Build->Settings->MCU C compiler->Includes and add the include path of the inc folder of the library project. The go to C/C++ Build->Settings->MCU Linker->Libraries and add the library file WITHOUT the lib in front of the file name, hence just JPEG. Also add the library search path below (point to the lib folder).
That's all!

eclipse include custom files (c)

Not sure how to phrase the question.
I've created a few files for my c project that I would like to use for multiple projects.
Project root: ~/workspace/myproject
Files :
~/workspace/myproject/customlib/myfile.h
~/workspace/myproject/customlib/myfile.c
I was able to move them from my eclipse (Code Composer Studio) workspace and replace them with symlinks to their new location.
Custom lib dir: ~/myfiles/customlib
This is working fine but I'd rather not use the symlinks as it becomes necessary to add those symlinks to any project where I want my customlib files. Also when copy/pasting a project in eclipse it doesn't seem to understand the symlink and creates a copy of the file rather than the symlink.
I've set up an include path to ~/myfiles/ but when I compile I get a bunch of unresolved symbol errors.
My custom files depend on files from other include paths as well. (if that might be a hint as to why things are breaking)
Is there another way I can link in these files?
I figured out how I can do what I'm looking for but can't actually post the answer for 8 hours so I'll answer it here.
I was able to add the .c files as "Linked Resources" to my project.
So in the end I had an include path to ~/myfiles and a linked resource ~/myfiles/customlib/myfile.c.
Linked Resources can be found under Project Properties -> Resource -> Linked Resources -> Linked Resources(tab)
Unfortunately, my environment, Code Composer Studio 6 on Ubuntu would not allow me to actually add a linked resource through the IDE.
As a workaround I added the linked resource directly to the .project file.
~/workspace/myproject/.project
Under the section labeled "natures" I added
<linkedResources>
<link>
<name>myfile.c</name>
<type>1</type>
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/myfiles/customlib/myfile.c</locationURI>
</link>
</linkedResources>
The "$%7BPARENT-2-PROJECT_LOC%7D" refers to ~/workspace/myproject/../../ (a.k.a. ~/). The 2 tells it how many ../'s
In case you don't get the locationURI right the first time you should be able to edit the file path from Project Properties -> Resource -> Linked Resources -> Linked Resources(tab)
You can use any defined build variables for the locationURI. Here is another way to write the location URI. PROJECT_LOC/../../myfiles/customlib/myfile.c
Since this is an eclipse project file it will be overwritten with whatever eclipse decides is the proper format for locationURI
You can place the linked resource into a folder in your project by modifying the tag. projectsubfolder/myfile.c. This will create a folder projectsubfolder under your project directory. ~/workspace/myproject/projectsubfolder
Unfortunately this isn't an optimal solution as I will need to add linkedresource entries for every source file I create in my custom lib. CCS fumbles the linked resources when doing a project copy/paste, requiring you to add the linked resources again to your copied project.
In the end it feels like a solution but it really doesn't have much benefit over symlinked files. The only one being that when I copy/paste a project I will know the project isn't using the correct files when it doesn't compile. (symlinking will make a working project with copies of the files instead of the originals)
I imagine I will need to learn about creating .lib files to make the inclusion a little more pain free.

You must select a host application to "run" a library

I am working with Code::Blocks and trying to program with the C language. I have created a header file, an implementation file and the main. When I compile, I have no errors, but when I run it I get the following error.
You must select a host application to "run" a library...
The libraries are all in the same folder.
I also did include the header files in my main program.
I have tried on 2 different PCs, and it didn't work. i tried with a different piece of code and it worked flawlessly.
What should I do?
Thanks.
EDIT: Solved.
Go to Project -> Properties -> Build Targets
From the 'Type' drop down list select 'Console Application' (in my case).
Seems like you have created dll. Change to executable.
You may find details how to fix it/
Properties -> Build Target -> 'Type' -> Console application
https://stackoverflow.com/a/8506935/2648826
You have it set up to build a library, not an application.
In File->New Project, you need to choose 'console type'

Resources