Monthly Archives: September 2014

Complains about GCC

I’m working on a small Chinese text parser plugin for MySQL 5.6, I’ll write another blog post about it.

The problem that made me to write this blog post, is quite a simple one.

Since I’m working on the Chinese text parser, I need a Chinese tokenizer library, and written in C.

I choosed Libmmseg, as stated above, I’ll write about it in another blog post.

I tried to write a small application using libmmseg, and made it compiled on my MBP.

Then, I need to transfer the application to a linux system(CentOS 6.5) and make it compile again.

Then, I got the problem.

The problem is something like this:

/tmp/ccsP9If4.o: In function `segment(char const*, css::Segmenter*)':
mmseg_test.cc:(.text+0x1af): undefined reference to `css::Segmenter::setBuffer(unsigned char*, unsigned int)'
mmseg_test.cc:(.text+0x1e6): undefined reference to `css::Segmenter::peekToken(unsigned short&, unsigned short&, unsigned short)'
mmseg_test.cc:(.text+0x207): undefined reference to `css::Segmenter::popToken(unsigned short, unsigned short)'
mmseg_test.cc:(.text+0x267): undefined reference to `css::Segmenter::peekToken(unsigned short&, unsigned short&, unsigned short)'
mmseg_test.cc:(.text+0x2af): undefined reference to `css::Segmenter::popToken(unsigned short, unsigned short)'
mmseg_test.cc:(.text+0x30b): undefined reference to `css::Segmenter::thesaurus(char const*, unsigned short)'

That’s quite strange, since I have compile the libmmseg and install it to /usr/local/lib, and added the dependency, but the ld still can’t find the library…… WTF!!!!

I tried lots of the ways, I even compile and try to link the objects by hand, and still can’t be done.

I’m frastrated.

Then I see this.

It said:

The trick here is to put the library AFTER the module you are compiling. The problem is a reference thing. The linker resolves references in order, so when the library is BEFORE the module being compiled, the linker gets confused and does not think that any of the functions in the library are needed. By putting the library AFTER the module, the references to the library in the module are resolved by the linker.

This saved my life!!!!

So, this is the reason I wrote this small blog post, the God D*mned GCC!!!!! Why it is so stupid like this when llvm can handle this beautifully?

I suddenly get understand why Apple give up it and using llvm instead, sure, I’ll try to use llvm myself instead of gcc too.

Sorry RMS and GNU.

Thinking about Note taking tools, seriously

Let’s talk about note taking, seriously.

Why I need to do this? There is lots and lots of note taking application and tools there in OS X.

And, even Apple has a nice note taking tools called Notes(yes, maybe not that good), and the famous Evernote (They did very good job on Notes, I must admit).

So, then, why I think there is the needs for a new note taking tool?

A shot answer, they are build for normal users, not for programmers.

And for the long answer, I’ll begin the requirements of note taking tool for programmers.

Here is the points:

  1. It (the note taking tool for programmers) must have the ability of bring out to you any time you want it, no interupt or changing the envronment (just like Dash run in the headless mode, yes, I like Dash very much!), it can be achieve by assigning a global shortcut key to the HUD window
  2. It must have the ability of saving the note you have taken as soon as you taken it, and store it even the application is quit, so you can view the notes next time you open it
  3. It should save the notes in the cloud, so that you can use the note you taken on every computer
  4. It should have the ability of store and showing Rich Text Format
  5. It should have the ability of Syntax coloring for the code snippets, and yes, by guessing or set (can be done using plugins)
  6. It should have the ability of text transforming (such as RTF to plain txt, Markdown or RST transform to HTML or other format, via plugins, of cause)
  7. It must interact with the clipboard

That’s why I think there should be a note for programmers.

I, as a programmer, really needs some text transformer or a shelf to come just as I called, it will just jump to me without let me goto desktop from my full screen application.

And, after that, it will send the text transformed to the clipboard(just plain text in most times), and just go away(with my text stored for next usage).

I have tried every note taking tools I can get, but none of them support my points.

They are beautiful, elegant and powerful, can even sync with my iPhone, but, they can’t answer for my requirement 1,5,6 (and that’s the function I want most).

So, I want to start a note taking tool on my own.

I’ll opensource it on Github when I finished the basic functions.

Go back to coding now.

A little complain about launchctl

It’s been a quite while since my last post.

That’s because I’m working something big on PHP, I’m writing a right and agile PHP development framework right now, and it has nearly finish the alpha stage.

I’ll make it to the world and open source it when I finish it.

Here is a few features features I’d like to talk about:

  1. Based on CI (using the methodology and definitions of CI), for agile and quick development, and easy to understand or put hands on it
  2. Fully support responsive design leveraging less and bootstrap 3.0
  3. Template functions from Smarty(and lots of plugins)
  4. Very smart image responsive support, leveraging a slightly modified of jquery-piciture and php-imagick, can get the picture any size you like on the fly
  5. Very smart Datatable Master view, using jquery-datatables, integrade datatable as Master view in the deep of controllers, coding master view couldn’t be more easier
  6. Very smart alternative Listview Master View, using the same methodlogy of jquery-datatables, and have 2 modes of the responsive design
  7. AOP support for PHP, can use regex and other string tools to intercept the controller methods(for security, transaction, auditing and logging usages)
  8. Sophisticated designed security mode, can be configured using database of template file, and using AOP to do the security, without invading the code

I can make quite a long list for this.

But, I have to stop, since, this post is for a little complains about launchctl.

launchctl is the fundamental application for OS X, it handles all the deamon processes, and it can do lots of things.

I won’t state lots of launchctl here, you can view the tutorial about it here.

Here is my complain.

I use vim in work a lot. As everyone knows, vim support ctags to do the synbol navigation.

But keeping update ctags’s tag file when updated the code is quite tiresome.

So, I tried to add some auto execution scripts to let ctags update my tags file automatically after a short time interval(1 minute, for example).

Yes, I can use crontab to do this. But, since I’m using OS X(and love it so much), I want to be more appleish, so I gave launchctl a try.

I tried the example here, it is a brilliant tutorial, but, the sample it brought is not the correct one!!!!!

Here is the sample it provided:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
        <key>label</key>
        <string>com.devdaily.pingwebsites</string>

        <key>ProgramArguments</key>
        <array>
                <string>/Users/al/bin/crontab-test.sh</string>
        </array>

        <key>OnDemand</key>
        <false/>

        <key>Nice</key>
        <integer>1</integer>

        <key>StartInterval</key>
        <integer>60</integer>

        <key>StandardErrorPath</key>
        <string>/tmp/AlTest1.err</string>

        <key>StandardOutPath</key>
        <string>/tmp/AlTest1.out</string>
</dict>
</plist>

See the problem???

You’ll be confuse as I was.

Yes, the problem is here:

        <key>label</key>

You should use Label instead of label, or launchctl won’t recognise this plist!!!!!!

And, investigate more carefully, you can see, all the key is capitalised but the label!!!!!

Are you kidding me?!

I google about 10 minutes about this problem(or maybe 30 minutes more, since I use the time reading when the page is loading, no kidding, I’m in mainland China, and must get pass the GFW to access google, yes!)

And after that, launchctl still won’t work, it complains:

launch_msg(): Socket is not connected

This is quite a difficult problem, and quite few articles about it. Yes, when you know the answer, you can know why.

I tried to fix this problem, for about 1 hour, just reading the post or other things. Frustrated nearly gave up.

And, I came across 1 forum post(sorry, forgot the url), it says this problem can be found in iTerm2 only, and won’t in the native terminal.

I tried, and, get passed!!!!!

So, this is a defect of iTerm2. This bug nearly let me gave up OS X, thanks, at least I knew where the problem is and can get my time to do something more useful.

I don’t know if the defect has been submitted in iTerm2’s bug tracker, so I have submitted the defect to them, the defect I submitted is here