"symbol not found" in C codes of makefile project in xcode - c

I create a makefile project in xcode4.5 (OSX -> Other -> External Build System) and add some c files into it. And I can make the project successfully.
But it tells me "symbol not found" when I try to jump to the definition of a function.
I try some ways from google, such as delete the xcworkspace and xcuserdata folders and delete derived data of project and so on. But all they fail. Any solutions?
BTW, my project is very simple and locates here.

Makefile and code works fine commandline.
Setup a quick project in xcode (5.1.1 btw, it's what I have
installed)
OSX->Other->External Build System
Set the project directory to the git checkout in the project creation
wizard.
In the External Build Tool Configuration->Info, set the Directory to
the git checkout directory.
Product->Build
Builds fine, runs fine.
Nothing more can be done to help if there isn't a something in the steps I took that helps, would have to look at a dmg of your xcode project.

Related

Building Anjay tutorial codes

I'm getting some difficulties on building the tutorial codes of Anjay https://github.com/AVSystem/Anjay. the doc wasn't really helpful.
I tried a simple :
cd examples/tutorial/custom-object
cmake . && make
but I'm getting this message :
By not providing "Findanjay.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "anjay", but
CMake did not find one.
Could not find a package configuration file provided by "anjay" with any of
the following names:
anjayConfig.cmake
anjay-config.cmake
Add the installation prefix of "anjay" to CMAKE_PREFIX_PATH or set
"anjay_DIR" to a directory containing one of the above files. If "anjay"
provides a separate development package or SDK, be sure it has been
installed.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.10)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
I would appreciate any suggetions.
Thank you.
I was doing the same thing. The error is because you have not installed anjay libraries on your local system or provide a way for CMake to find it.
I installed it by following steps mentioned in compilation docs
In the root of Anjay directory execute the following:
cmake . && make && sudo make install

how to run existing C file onto Xcode have

I'm new on Xcode.
I need to make some files run:
they are the implementation of a model that I'd like to apply on my dataset, but at the moment I cannot use them.
Inside the folder there are:
main.cc, Makefile, README
and other files with extentions
.cc,
.c,
.h,
.yld,
.lt
How do I put them on Xcode? And how can I run them from the Terminal?
I have:
OS X El Capitan;
Xcode Version 7.3.1 (7D1014)
Thank you in advance for your help! :)
You can set your build target to be the makefile, but, this will not give you all of Xcode's benifits as an IDE. As far as I know, importing a Makefile based project into Xcode is not easy.
Here is a blog post detailing one example.
You could create a new project with your desired language, and add files to it.
As for how to run from terminal, you cd to project directory, and then you type make. Then you find name of the program created, and you type ./[PROGRAM] to execute it.

CMake: Header files cannot be opened

I am working to build a Code Composer Studio project using cmake, which is new to me. It builds successfully under Linux but I am struggling to get it to work under Windows. The cmake command executes without issue, but make fails during the very first C object at the very first #include with the error code
fatal error: could not open source file "stdbool.h" (no directories in search list)
I'm using the libraries included in CCS's compiler (c6000_7.4.15), and that whole folder is included in the CSS project. I include it in cmake as well. In my .cmake file:
set (CCS_ROOT ${CCS_ROOT_V6_WIN} CACHE PATH "code composer install directory")
set(CGT_COMPILER_ROOT ${CCS_ROOT}/tools/compiler/c6000_7.4.15 CACHE INTERNAL "DSP Compiler Root")`
And in the CMakeLists.txt file:
set (COMPILER_INCLUDE ${CGT_COMPILER_ROOT}/include)
INCLUDE_DIRECTORIES ("${COMPILER_INCLUDE}")
Why can the header files not be opened when they're linked in the project and CMake can find them just fine?
EDIT: The directory structure had been changed underneath me, so I took the opportunity to add all of the external files directly into the project to make it completely platform-independent. That way, since the project is managed by our Git repository, users won't have to install the CSL or any other programs to build the project. This also means that paths to libraries and header files will never change between revisions and environments.
Unfortunately, this has not solved my problem. The project continues to build in Linux while failing to ind the very first included header file. I also notice that, under Windows, it cannot find my own header files unless I provide a relative path, e.g. #include "../Common.h" I can get make to find stdbool.h if I provide an absolute path to the compiler directory, but that exposes a web of additional broken links between files.
As a side note, the project builds successfully within Code Composer Studio, so I am assuming that this isn't an issue with my specific Windows environment nor with the code within the project itself.
This seems to be an issue with gcc.exe. I set an environment variable CC to the path of a different compiler (in my case a TI compiler) within my build script and that fixed the problem.

How do you configure XCode to find header files and symbols in an "External Build System" project

I'm trying to set up an XCode 5.1 project for C php-extension development. This is essentially a GNU autoconf/automake project with one prerequisite step.
I created a new "External Build System" project. I then made two targets, one that runs the prerequisite "phpize" command that creates GNU autoconf files. I have another target that runs the GNU ./configure script. This all works great.
Next, I tried adding my .c and .h files to the project. When I open them, and try to click on any #include .h file or any external symbol, XCode says "symbol not found", even for system stuff like <stdio.h>.
In a normal XCode project, there is a way to configure the header/include search paths. With this external build system project, I see no way to do this.
My questions:
For a project that uses ./configure and make, is the "External Build System" project type the correct type?
If so, then in this project type, how do I set the header/include search paths so that code navigation works?
Analyze doesn't seem to work right, either.

Any possible way to use Tokyo Cabinet in Eclipse?

Just spend 3 straight hours trying to solve the java.lang.UnsatisfiedLinkError: no jtokyocabinet in java.library.path problem in Eclipse in Linux.
Downloaded TC and TC-Java sources,
Built them both using ./config --prefix=/usr (so everything "JNI" related should be in /usr/lib)
Set the LD_LIBRARY_PATH=/usr/lib and CLASSPATH="$CLASSPATH:/usr/local/lib/tokyocabinet.jar" and exported both in .profile
Imported tokyocabinet.jar into the project.
Am I missing a setting other than the proper -Djava.library.path=. settings? I can't even find anything on the net about jtokyocabinet on the web or in the documentation. What's the secret sauce to getting this thing to work?
try to make a link to libjtokyocabinet.so...0 in your JAVA_HOME/jre/lib/i386.
it is because your code can not find tokyocabinet's *.so and *.a files, usually they are in /usr/local/lib, run the following command:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
and then try your code again.
Have the same problem, in my case, using OpenSUSE 12.3 64 bits and Eclipse.
First, the kyotocabinet-java package can be downloaded from this repository:
http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_12.3/
This package provide /usr/lib64/libjkyotocabinet.so.1.1.0 that is the library used by the kyotocabinet jar you can get from maven or the official site.
Looking for this lib I found that there is created a slink:
xxxx#xxxx:/usr/lib64> ls -al /usr/lib64/libjkyoto*
/usr/lib64/libjkyotocabinet.so.1 -> libjkyotocabinet.so.1.1.0
/usr/lib64/libjkyotocabinet.so.1.1.0
I just created a new slink without the ".1" at the end...
sudo ln -s libjkyotocabinet.so.1.1.0 libjkyotocabinet.so
/usr/lib64/libjkyotocabinet.so -> /usr/lib64/libjkyotocabinet.so.1.1.0
And all worked alright, seems that
System.loadLibrary("jkyotocabinet");
don't work if the library name is ended with something different to ".so"
Yes, you're missing something. Eclipse controls its own classpath, so whatever you set up in the environment outside Eclipse is likely not to have any effect.
You need to go into the properties for your project, find the "Build Path" settings and add the path to your tc.jar (or jars) to your build path there.
It may be easier to set up a /lib directory within your eclipse project, copy your tokyo jar there and add that to your build path. That way, it becomes part of your project (and can move from Eclipse installation to Eclipse installation) rather than being an external system dependency.

Resources