cocos2dx Undefined symbols for architecture i386: Error - cocos2d-x

Just now i have created a cocos2d-x project on my mac, Iam using ios version project for development. Iam new to cocos2dx and cpp. When i have first run the project in Xcode its perfectly run's fine. But When i add a touches methods in HelloWorldScene.h file its showing the Error as i run the project. what i have added is after include i have added the namespace cocos2d and after the static method CREATE_FUNC(HelloWorld); i have added touch event method,
virtual void ccTouchesEnded(CCSet* pTouches, CCEvent* event);
When i build and run the project iam getting a error, the error is.
Undefined symbols for architecture i386:
"HelloWorld::ccTouchesEnded(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for HelloWorld in HelloWorldScene.o
"non-virtual thunk to HelloWorld::ccTouchesEnded(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for HelloWorld in HelloWorldScene.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

For virtual function, in .h file, the definition is:
virtual void ccTouchesEnded(CCSet* pTouches, CCEvent* event);
Then in .cpp file, no need 'virtual':
void HelloWorld::ccTouchesEnded(CCSet* pTouches, CCEvent* event){ ... };
I guess the problem is here.

Related

Linker can't find 'get_int_member_with_default' from json-glib

I am currently working on a library that interacts with a REST API. This API responds with a JSON object, which I'm parsing with json-glib-1.0. As some of the members of the object might not exist I wanted to use the get_x_member_with_default function of the Json.Object class.
Even though both the Vala and the C compiler see the functions the linker gives me several errors:
Undefined symbols for architecture x86_64:
"_json_object_get_boolean_member_with_default", referenced from:
_discord_message_construct in message-f5c60f.o
"_json_object_get_int_member_with_default", referenced from:
_discord_message_construct in message-f5c60f.o
"_json_object_get_string_member_with_default", referenced from:
_discord_message_construct in message-f5c60f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To reproduce this you can try this code:
void main() {
string json = "{\"one\": 1337}";
Json.Parser parser = new Json.Parser();
parser.load_from_data(json, -1);
int64 val = parser.get_root().get_object().get_int_member_with_default("one", 666);
stdout.printf(#"$val\n");
}
and compile it with this command: valac --pkg json-glib-1.0 file.vala.
This gives me
Undefined symbols for architecture x86_64:
"_json_object_get_int_member_with_default", referenced from:
__vala_main in json2-ec99c2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is obviously not a library; when compiling my library I only generate the C code and compile and link everything with the output of pkg-config --cflags --libs json-glib-1.0. Is there anything I have to link additionally?
You need to install a newer version of json-glib, or more likely, not use that symbol. The Vala documentation for the symbol shows this is since version 1.6 of the library. This information is taken from the C source for the library and the symbol was added with this commit. The problem is the latest stable release appears to be 1.4.4 - see the source repository tags. So it looks like you have to build your own development version with the latest symbols or not use get_int_member_with_default ().

Linker Command Failing - Undefined symbols for architecture armv7

I am trying to install the Google Maps Utils plugin via cocoapods so I can utilize the clustering functionality. I have followed the setup guide provided by google step by step however I am getting a build error during the linking process.
The error I get is:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_POIItem", referenced from:
objc-class-ref in MainViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone have a solution to this? I have tried just about everything I could find on the web.
Thanks in advance!
EDIT:
I have defined the POIItem as follows:
#import "ViewController.h"
#import <Google-Maps-iOS-Utils/GMUMarkerClustering.h>
#import <GoogleMaps/GoogleMaps.h>
// Point of Interest Item which implements the GMUClusterItem
protocol.
#interface POIItem : NSObject<GMUClusterItem>
#property(nonatomic, readonly) CLLocationCoordinate2D position;
#property(nonatomic, readonly) NSString *name;
- (instancetype)initWithPosition:(CLLocationCoordinate2D)position name:(NSString *)name;
#end
and here is a link to the set up guide I followed: Google Guide

Data does not exist in the namespace System

Can anyone throw any light on the following error importing System.Data:
/home/baloo/HellooCSharp/HellooCSharp/HellooCSharp.cs(14,14): Error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing `System.Data' assembly reference? (CS0234) (HellooCSharp)
Build command:
Building: HellooCSharp (Debug|x86)
Performing main compilation...
/usr/bin/mcs /noconfig "/r:/usr/lib/mono/4.5/mscorlib.dll" -nostdlib "/out:/home/baloo/HellooCSharp/HellooCSharp/bin/Debug/HellooCSharp.exe" "/r:/usr/lib/mono/4.5/System.dll" "/r:/usr/lib/mono/4.5/System.Core.dll" /nologo /warn:4 /debug:full /optimize- /codepage:utf8 /platform:x86 "/define:DEBUG" /t:exe "/home/baloo/HellooCSharp/HellooCSharp/Properties/AssemblyInfo.cs" "/home/baloo/HellooCSharp/HellooCSharp/HellooCSharp.cs"
Compilation failed: 2 error(s), 0 warnings
The assembly ca be found in /usr/lib/mono/4.5, which has been duly configured in the build assembly folders preferences dialog. [Edit: mcs compiles the test code fine with this added to the command line.]
Fedora 23, mono-core and -data rpm version 4.0.5. [Edit: MonoDevelop Version 5.9.7 (build 9)]
Hint: Are you missing `System.Data' assembly reference?
You need to reference System.Data in order for it to be found/resolved.
Importing System does not import System.Data
To resolve this you just need to do edit edit references and check the system.Data.

Can not launch ipad-iphone simulator in libgdx project

I am developing a libgdx project. I want to deploy the project to android and ios. The project is working on desktop(MacOS) ,android simulator and android device. However, when I try to launch IOS simulators with gradle or main class, errors are throwed. Also I downloaded some another robovm example. These projects can launch simulators with similar code.
Libgdx IOS main class is as follows:
public class IOSLauncher extends IOSApplication.Delegate {
#Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new DemoProject(), config);
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
}
}
Error is as follows:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.robovm.rt.VM.getStackClasses(II)[Ljava/lang/Class;
at org.robovm.rt.VM.getStackClasses(Native Method)
at org.robovm.rt.bro.Bro.bind(Bro.java:50)
at org.robovm.objc.ObjCRuntime.<clinit>(ObjCRuntime.java:43)
at org.robovm.objc.ObjCObject.<clinit>(ObjCObject.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
In fact, I prefer to run gradle.
But it throws error is as follows:
Executing external task 'launchIPhoneSimulator'...
Configuration on demand is an incubating feature.
:core:compileJava UP-TO-DATE
:core:processResources UP-TO-DATE
:core:classes UP-TO-DATE
:core:jar UP-TO-DATE
:ios:compileJava UP-TO-DATE
:ios:processResources UP-TO-DATE
:ios:classes UP-TO-DATE
:ios:jar UP-TO-DATE
:ios:assemble UP-TO-DATE
:ios:compileTestJava UP-TO-DATE
:ios:processTestResources UP-TO-DATE
:ios:testClasses UP-TO-DATE
:ios:test UP-TO-DATE
:ios:check UP-TO-DATE
:ios:build UP-TO-DATE
:ios:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ios:launchIPhoneSimulator'.
> Failed to launch IOS Simulator
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.743 secs
/Users/burakdagli/.m2/repository/org/robovm/robovm-dist/1.2.0/unpacked/robovm-1.2.0/bin does not exist.
14:34:13: External task execution finished 'launchIPhoneSimulator'.
How can I proceed?

Unexpected function call

I'm using MySQL 5.0.51a and I uncovered a bug which was causing an infinite loop (ending in a stack overflow and seqgfault) when my program was exiting.
I discovered that if I had a function called shutdown(), it would be called by during a call to mysql_close().
I've included a mimimal example C source file and makefile below to show the issue in action.
In the example, shutdown() gets called despite not being called by main().
What is going on here? Is my shutdown() clashing with a shutdown() in libmysqlclient?
If so, is there a reason gcc doesn't know about it?
I'm using gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
mysql_shutdown.c:
#include <stdio.h>
#include <mysql/mysql.h>
#define HOST "<hostname>"
#define USER "<username>"
#define PASSWD "<password>"
#define DB "<dbname>"
MYSQL *connection;
void shutdown(void)
{
printf("shutdown called\n");
}
int main()
{
connection = mysql_init(NULL);
mysql_real_connect(connection, HOST, USER, PASSWD, DB, 0, NULL, 0);
mysql_close(connection);
return 0;
}
makefile:
mysql_shutdown: mysql_shutdown.c
gcc -Wall -Wextra -Werror `mysql_config --cflags` -o $# $^ `mysql_config --libs`
Output:
$ ./mysql_shutdown
shutdown called
Note that this appears to be the opposite behaviour to that shown in GCC function name conflict. In that case the expected function wasn't being called, whereas in my case, a function is being called when it isn't expected.
What's most likely happening is that, because mysql_config --libs is giving you a list of the MySQL library files and the shutdown() function is in a different object file within the library(s), it's not being bought in.
You have to understand the way most linkers work. What they will do is tie together all the object files that you list explicitly and you end up with a partial executable and a list of symbols that have yet to be resolved.
Then the libraries are searched in an effort to resolve those symbols, by locating the object files within those libraries which can resolve the symbols. Normally what may happen is that you'll find mysql_close() in one of the libraries and load up its object file from that library. But that action may introduce more symbols that need resolving, which can in turn lead to more libraries being searched.
As an example, let's say mysql_close() calls shutdown() which is normally provided in one of the MySQL libraries. However, because you've already defined it, the loading of mysql_close() does not result in having an unresolved shutdown symbol. So there's no need to go looking for it in any of the libraries.
It does result in mysql_close() calling a totally different shutdown(), the one you provided in your code.