Is there a way to use boost threads and asio in native-client? - boost-asio

I'm trying to port some existing code that uses boost into native-client.
I compiled boost according to the instructions here: https://code.google.com/p/naclports/wiki/InstallingSDL (with boost instead of sdl), and tried injecting some boost code into one of the examples.
I was successfully able to use a boost::shared_ptr by editing examples/api/socket/socket.cc by including the header and adding a simple test method:
#include <boost/shared_ptr.hpp>
The test method:
void ExampleInstance::test_shared_ptr() {
boost::shared_ptr<std::string> test_ptr(new std::string("hi"));
PostMessage(test_ptr->c_str());
}
Invoking this method from the constructor results in a "hi" appearing on the console when loading the page you can reach by running "make serve".
Although I'm deeply impressed that this much works, my app uses boost::thread and boost::asio, and there I ran into trouble. In pepper_34, if I add:
#include <boost/threads.hpp>
I get these compilation errors, just by including that file:
~/nacl_sdk/pepper_34/examples/api/socket$ make
CHROME_PATH is undefined, and google-chrome not found in PATH, nor /usr/bin/google-chrome.
CXX newlib/Release/socket_x86_32.o
In file included from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/thread_only.hpp:17,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/thread.hpp:12,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread.hpp:13,
from socket.cc:25:
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/pthread/thread_data.hpp: In member function 'size_t boost::thread_attributes::get_stack_size() const':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/pthread/thread_data.hpp:63: error: invalid conversion from 'const pthread_attr_t*' to 'pthread_attr_t*'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/pthread/thread_data.hpp:63: error: initializing argument 1 of 'int pthread_attr_getstacksize(pthread_attr_t*, size_t*)'
make: *** [newlib/Release/socket_x86_32.o] Error 1
Likewise, if I try to include any of the basic asio elements, for instance:
#include <boost/asio/io_service.hpp>
I get these compilation errors after adding that #include line:
~/nacl_sdk/pepper_34/examples/api/socket$ make
CHROME_PATH is undefined, and google-chrome not found in PATH, nor /usr/bin/google-chrome.
CXX newlib/Release/socket_x86_32.o
In file included from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/posix_fd_set_adapter.hpp:26,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/fd_set_adapter.hpp:22,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/select_reactor.hpp:27,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/reactor.hpp:29,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/task_io_service.ipp:24,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/task_io_service.hpp:203,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/impl/io_service.hpp:71,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/io_service.hpp:767,
from socket.cc:25:
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/socket_types.hpp:283: error: 'IF_NAMESIZE' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/socket_types.hpp:304: error: 'sockaddr_un' does not name a type
In file included from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/socket_ops.hpp:326,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/select_reactor.ipp:30,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/select_reactor.hpp:212,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/reactor.hpp:29,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/task_io_service.ipp:24,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/task_io_service.hpp:203,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/impl/io_service.hpp:71,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/io_service.hpp:767,
from socket.cc:25:
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::close(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:342: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'bool boost::asio::detail::socket_ops::set_user_non_blocking(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:384: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'bool boost::asio::detail::socket_ops::set_internal_non_blocking(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:437: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'bool boost::asio::detail::socket_ops::sockatmark(boost::asio::detail::socket_type, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:617: error: '::sockatmark' has not been declared
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'size_t boost::asio::detail::socket_ops::available(boost::asio::detail::socket_type, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:637: error: 'FIONREAD' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'void boost::asio::detail::socket_ops::init_buf(boost::asio::detail::socket_ops::buf&, void*, size_t)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:687: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:688: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'void boost::asio::detail::socket_ops::init_buf(boost::asio::detail::socket_ops::buf&, const void*, size_t)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:698: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:699: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::ioctl(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, int, boost::asio::detail::ioctl_arg_type*, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1689: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'const char* boost::asio::detail::socket_ops::inet_ntop(int, const void*, char*, size_t, long unsigned int, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1974: error: 'IF_NAMESIZE' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1979: error: 'if_name' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1979: error: 'if_indextoname' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1981: error: 'if_name' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::inet_pton(int, const char*, void*, long unsigned int*, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:2209: error: 'if_nametoindex' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::gethostname(char*, int, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:2251: error: '::gethostname' has not been declared
make: *** [newlib/Release/socket_x86_32.o] Error 1
(Side Note: I don't think the CHROME_PATH warning at the top is causing these errors, since I get the same warning for the examples even without my edits, but the examples still work. I imagine it's because I'm building on a vm without chrome installed (or a window manager in which to run it), since I had to use linux to build boost according to the error message the boost build process gave when I tried building it on OSX. The error messages suggest this interferes with "make run_package", but otherwise the examples run properly under "make serve", and can be tested from a different machine, using chrome to access the pages. I'm writing this question while waiting for chromium-browser to install, in hopes I can confirm that theory.)
In case it matters, I'm running Ubuntu 12.04.
My questions:
Is there a previous pepper version in which somebody has successfully used boost::asio and/or boost::threads?
Has anyone encountered this problem and discovered a workaround?

Try building the glibc build of boost instead of newlib. You can do this by running:
TOOLCHAIN=glibc make boost
from the naclports directory.
It seems that the newlib build of boost doesn't support many boost libraries:
Component configuration:
- atomic : not building
- chrono : not building
- context : not building
- coroutine : not building
- date_time : building
- exception : not building
- filesystem : not building
- graph : not building
- graph_parallel : not building
- iostreams : not building
- locale : not building
- log : not building
- math : not building
- mpi : not building
- program_options : building
- python : not building
- random : not building
- regex : not building
- serialization : not building
- signals : not building
- system : not building
- test : not building
- thread : not building
- timer : not building
- wave : not building
The glibc build seems to support many more libraries:
Component configuration:
- atomic : building
- chrono : building
- context : not building
- coroutine : not building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- log : building
- math : building
- mpi : not building
- program_options : building
- python : not building
- random : building
- regex : building
- serialization : building
- signals : not building
- system : building
- test : building
- thread : building
- timer : building
- wave : building

Related

USBKeyboard undefined when compiling for K22F

I'm compiling a very simple mBed OS 6 (bare metal) program that uses USBKeyboard for the FRDM-K22F, but I get this link error:
[Error] #0,0: L6218E: Undefined symbol USBKeyboard::key_code(unsigned char, unsigned char) (referred from BUILD/K22F/ARMC6/main.o).
[Error] #0,0: L6218E: Undefined symbol USBKeyboard::USBKeyboard(bool, unsigned short, unsigned short, unsigned short) (referred from BUILD/K22F/ARMC6/main.o).
Those functions are defined in USBKeyboard.cpp but I'm not sure how to make mBed Studio actually link it.
I posted this on the Mbed forum too and got a solution there:
if you have in your mbed_app.json file only this content
{
"requires": ["bare-metal"]
}
then you probably need to change it to
{
"requires": ["bare-metal", "events", "drivers-usb"]
}
This seems to be incorrectly documented.

Flutter Fails on Run (or upgrade, or anything else).

I have been getting a massive error recently, upon Running any of my flutter applications in Intellij, Visual Studio, etc. I cannot perform git functions because of it either. Any help would be greatly appreciated.
(Some parts omitted - this snippet represents the 40k line code pattern)
Launching lib/main.dart on iPhone X in debug mode...
compiler message:
file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/widgets/editable_text.dart:439:9: Error: Type 'LayerLink' not found.
compiler message: final LayerLink _layerLink = new LayerLink();
compiler message: ^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:4474:20: Error: The method 'getLastTransform' isn't defined for the class 'invalid-type'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'getLastTransform'.
compiler message: return _layer?.getLastTransform() ?? new Matrix4.identity();
compiler message: ^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/proxy_box.dart:4501:18: Error: Method not found: 'FollowerLayer'.
compiler message: _layer = new FollowerLayer(
compiler message: ^^^^^^^^^^^^^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/texture.dart:76:7: Error: No named parameter with the name 'rect'.
compiler message: rect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
compiler message: ^^^^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:124:11: Error: 'ContainerLayer' isn't a type.
compiler message: final ContainerLayer rootLayer = TransformLayer(transform: _rootTransform);
compiler message: ^^^^^^^^^^^^^^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:124:38: Error: Method not found: 'TransformLayer'.
compiler message: final ContainerLayer rootLayer = TransformLayer(transform: _rootTransform);
compiler message: ^^^^^^^^^^^^^^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:124:38: Error: The method 'TransformLayer' isn't defined for the class '#lib1::RenderView'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'TransformLayer'.
compiler message: final ContainerLayer rootLayer = TransformLayer(transform: _rootTransform);
compiler message: ^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:125:15: Error: The method 'attach' isn't defined for the class 'invalid-type'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'attach'.
compiler message: rootLayer.attach(this);
compiler message: ^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:195:13: Error: The method 'addToScene' isn't defined for the class 'invalid-type'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'addToScene'.
compiler message: layer.addToScene(builder, Offset.zero);
compiler message: ^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:215:58: Error: The method 'find' isn't defined for the class 'invalid-type'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'find'.
compiler message: final SystemUiOverlayStyle upperOverlayStyle = layer.find<SystemUiOverlayStyle>(top);
compiler message: ^
compiler message: file:///Users/JohnnySmithh/Documents/flutter/packages/flutter/lib/src/rendering/view.dart:220:35: Error: The method 'find' isn't defined for the class 'invalid-type'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'find'.
compiler message: lowerOverlayStyle = layer.find<SystemUiOverlayStyle>(bottom);
compiler message: ^
Compiler failed on /Users/JohnnySmithh/IdeaProjects/MyCoolProject/lib/main.dart
Error launching application on iPhone X.
Exited (sigterm)
It's honestly a little hard to tell what's going on from just that error message. Do any errors show up in intellij before you build?
The only things I can think of are:
your flutter installation might be corrupted. You could try deleting and re-installing
your build directory might have something wrong. Try running flutter clean before building again
your libraries aren't being included properly. I'd assume this would show up in intellij, but maybe the paths are set differently there? Check Project Structure -> Libraries and see where the paths are set there.
(related to first) you might have multiple instances of flutter on your computer. If intellij is using one while the command line is using another that could potentially cause problems.
If your app happens to be open-source, or you're able to make a new app with the minimum amount of changes to reproduce the error, that would help significantly with diagnosing the problem =).

What library in OpenDDS contains "OpenDDS::DCPS::operator<<"?

I'm having an issue linking my shared library against an OpenDDS (v3.9) static library because I am unable to find where this method signature is located.
Here's the error.
[exec] libs/mylib/ABTypeSupportImpl.cpp:74: error: undefined reference to 'OpenDDS::DCPS::operator<<(OpenDDS::DCPS::Serializer&, short)'
[exec] collect2: error: ld returned 1 exit status
[exec] make: *** [/tmp/mybuild/lib_ab/obj/local/armeabi-v7a/lib_ab.so] Error 1
ABTypeSupportImpl.cpp is auto generated from compiling the IDL. More of the same errors follow. Because of the namespace (OpenDDS::DCPS), I would think this would be found within the library libOpenDDS_Dcps.a, but using nm on this lib and then grep'ing for "operator" or "<<", produces no results. Could it be that name mangling is a bit stranger for overloaded operators? I ran this on every library file within $DDS_ROOT/lib, but found nothing.
And if I recompile the IDL and remove member fields of structs with datatypes such as short or long, then there are no errors and everything links fine.
Anyone know what library this method signature might be located?
These operators are declared in 'dds/DCPS/Serializer.h' but implemented inline in Serializer.inl. Probably you compile OpenDDS with inlining enabled (its default) but when you compile your application you compile with inlining disabled.

Non-static data member error with clang but not g++

Summary:
I have a code snippet that compiles fine with g++ but not with clang.
Details:
I have a project that compiles fine with g++ but when compiling with clang I get an error about error: use of non-static data member. I tried to create a small test case that would demonstrate the problem, but for the small test case g++ gave the same error as clang.
I've posted a 236 line file to pastebin that demonstrates the problem:
http://pastebin.com/DGnfxmYe
When compiled with g++ 4.6.3 this works fine. But when compiled with clang 3.2 I get the following error messages:
myhashmap.hpp:169:29: error: use of non-static data member 'num_bins' of 'MyHashMap' from nested type 'iterator'
for (_index++; (_index < num_bins) && (bins[_index] == NULL); _index++)
^~~~~~~~
myhashmap.hpp:169:43: error: use of non-static data member 'bins' of 'MyHashMap' from nested type 'iterator'
for (_index++; (_index < num_bins) && (bins[_index] == NULL); _index++)
^~~~
myhashmap.hpp:171:17: error: use of non-static data member 'num_bins' of 'MyHashMap' from nested type 'iterator'
if (_index < num_bins) {
^~~~~~~~
myhashmap.hpp:172:17: error: use of non-static data member 'bins' of 'MyHashMap' from nested type 'iterator'
_theNode = bins[_index];
^~~~
Looking at the code, it makes sense to me why clang is giving these error messages. What I don't understand is why g++ compiled the code correctly in the first place. I did not write this code but I would like to get it to compile cleanly with clang. So I'm trying to understand exactly what it is doing. And I would be interested in understanding why it compiles with g++ but not with clang. Does g++ interpret the c++ standard differently, or is there some g++ extension that the code is taking advantage of?
It fails with GCC 4.8 (prerelease) so I assume it's a bug that's been fixed. I can't find a corresponding bug report though.
To fix the code I think you'll need add an int _num_bins member to the iterator and pass the cotnainer's num_bins to the iterator constructor in begin() and end(), so it's stored in each iterator object.
(Additionally, don't write (void) for a function taking no arguments, that's an abomination. In C++ a function taking no arguments is written ())

Migrating Gecko 1.9 to 2.0 - Lot of errors

OK, after migrated to Gecko 2.0 for my XPCOM Component,
I fixed a couple of thg like below:
1. Replacing #include "nsIGenericFactory.h" to #include "mozilla/ModuleUtils.h"
2. Replacing xpcomglue_s.lib to xpcomglue_s_nomozalloc.lib
3. Adding #include "mozilla-config.h" to xpcom-config.h header file
4. And as well as remove a couple of unused header file eg: nsReadableUtils.h, nsEventQueueUtils.h, nsIExtensionManager.h
5. Replacing NS_DEFINE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) to NS_DEFINE_STATIC_IID_ACCESSOR(IMyProgram, IMYPROGRAM_IID)
Reduced from 200+ errors to 20+ now, below are a few more errors which i have no idea what is that, any expert here encounter problem like below?
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
error C2084: function 'void nsTraceRefcnt::LogAddRef(void *,nsrefcnt,const char *,PRUint32)' already has a body
error C2084: function 'void nsTraceRefcnt::LogRelease(void *,nsrefcnt,const char *)' already has a body
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C2146: syntax error : missing ';' before identifier 'components'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2440: 'initializing' : cannot convert from 'const char [13]' to 'int'
error C2078: too many initializers
error C2448: 'NS_IMPL_NSGETMODULE' : function-style initializer appears to be a function definition
error C2143: syntax error : missing ';' before '__stdcall'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2556: 'int MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)' : overloaded function differs only by return type from 'nsresult MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)'
error C2371: 'MyProgramRegistration' : redefinition; different basic types
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
At the very least it looks as if you are missing an NS_DECLARE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) in your interface (xpidl would have generated that for you automatically.) Some of the other errors are a bit harder to figure out without source code, but the chances are that you haven't quite managed to update your module registration code correctly.