The Valley of the Wolves (2000) by Laura Gallego García, the first book in the Chronicles of the Tower series.
It was published prior to the date you said you read the book in question. The cover has a girl with black hair and a ghostly boy, as you described. And according to this review, the girl grew up on a farm, with a boy only she could see as a friend, until a mysterious magician showed up one day to take her away and make her his apprentice.
Beautiful elves, loyal dwarves, secret unicorns and vengeful ghosts pepper this colorful but hollow coming-of-age fairytale.
Dana is born on a dark and stormy night, when fierce winds pelt her tiny farmhouse, and the midwife sees sparks in her sapphire eyes. She grows up with only one friend, Kai, whom no one else can see—except a mysterious stranger, who arrives in Dana’s drought-plagued village and buys her from her loving parents. Dana becomes a magician’s apprentice in a remote tower surrounded by vicious wolves. Ambitious, Dana absorbs herself in her education, spending less and less time with Kai. If their friendship suffers a little, isn’t that a fair price to pay for gaining a magician’s golden tunic?
Dana’s coming-of-age quest is somewhat intriguing, but she herself is unfortunately flat. Like the similarly stock characters who people this world, she is a collection of traits rather than a character: born with power; budding sexuality; forced to choose between loyalty and ambition. Nonetheless, though shallow as a novel, Dana’s story makes a sweet fairytale.